I’m working on a macro that gathers a screenful of information, determines an email address, and creates an Outlook message with the scraped screen in the body.
My code works beautifully when run straight from Outlook; the problem is that when I have to update the code, I end up going desk to desk to get everybody up and running. I’m trying to migrate the code to Extra! Basic so that a) it can be run from an Attachmate toolbar button, and b) so that I can store the code on a network drive and make seamless updates.
Last week I deployed the Extra! version of the macro, and it ran fine for the first few days. Then on Friday I got reports of the following from a number of different users:
· The email was completed correctly on the user’s screen, but when she printed a copy only the To: & Subject: lines were shown. No text at all.
· When verifying the email in her sent messages folder, the user got a pop up stating "Can't open this item. Unknown error."
· The recipient was unable to open the message.
I had the same problems when I tried to use Excel as a platform to run the macro.
For Outlook, I used these object declarations:
For Excel, I used these object declarations:
Here’s what my Extra Basic code looks like (by the way, we’re running Extra 6.7 here):
Has anyone else run into this kind of problem? Is there something I should be doing differently in the code?
Thanks for your time and help!
My code works beautifully when run straight from Outlook; the problem is that when I have to update the code, I end up going desk to desk to get everybody up and running. I’m trying to migrate the code to Extra! Basic so that a) it can be run from an Attachmate toolbar button, and b) so that I can store the code on a network drive and make seamless updates.
Last week I deployed the Extra! version of the macro, and it ran fine for the first few days. Then on Friday I got reports of the following from a number of different users:
· The email was completed correctly on the user’s screen, but when she printed a copy only the To: & Subject: lines were shown. No text at all.
· When verifying the email in her sent messages folder, the user got a pop up stating "Can't open this item. Unknown error."
· The recipient was unable to open the message.
I had the same problems when I tried to use Excel as a platform to run the macro.
For Outlook, I used these object declarations:
Code:
Dim ns As NameSpace
Set ns = ThisOutlookSession.Session
Dim SDRequest As MailItem
Set SDRequest = CreateItem(olMailItem)
For Excel, I used these object declarations:
Code:
Set ol = CreateObject("Outlook.Application")
Set ns = ol.GetNamespace("MAPI")
Dim SDRequest As MailItem
Set SDRequest = ol.CreateItem(olMailItem)
Here’s what my Extra Basic code looks like (by the way, we’re running Extra 6.7 here):
Code:
global OutlookApp as object
global SDRequest as object
Sub Main
Set OutlookApp = CreateObject("Outlook.Application")
Set SDRequest = OutlookApp.CreateItem(0)
‘ code to initialize screen objects
‘ code to determine the appropriate recipient address
‘ code to get the screen information into the email
For ScreenLine = 4 To 11
ScreenArray(ScreenLine) = Sess0.Screen.Area(ScreenLine, 2, screenline,80)
Next ScreenLine
For ScreenLine = 4 To 11
BodyText = BodyText & ScreenArray(ScreenLine) & Chr(13)
Next ScreenLine
on error goto ErrHandler
SDRequest.Display ' this causes Outlook to ask whether to
‘ permit the use of the address book
' if the user says NO, there is an error
SDRequest.Recipients.Add (AppropriateEmailAddress)
SDRequest.Body = BodyText
SDRequest.Subject = SubjectLine
SDRequest.ReadReceiptRequested = True
End If
Cleanup:
set OutlookApp = nothing
set SDRequest = nothing
exit sub
ErrHandler:
msgbox("You chose not to allow the macro to access your address book. Unable to send request.")
SDRequest.Delete
resume Cleanup
End Sub
Has anyone else run into this kind of problem? Is there something I should be doing differently in the code?
Thanks for your time and help!