×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Sending an email from Attachmate

Sending an email from Attachmate

Sending an email from Attachmate

(OP)
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:

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!

RE: Sending an email from Attachmate

(OP)
Just to let you all know, the answer was dropped into my lap by accident late last week.  It turns out that all of my coding was correct.  BUT..., if the user makes any changes whatsoever to the email created by the macro, that's when the problems crop up.  The users were adding their signatures to their emails.  This wasn't a problem when the macro was being launched from Outlook itself, but became a problem when the macro was running from Attachmate.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close