Link to home
Start Free TrialLog in
Avatar of pemurray
pemurray

asked on

How to prevent Outlook from popping up the address booking when sending an email via Powerbuilder

Hello everyone,

When I connect to Outlook to send an email it pops up the address book even though I am specifying the emails correctly.

Is there a way to prevent this?

Here is my current code:

mailSession mSes

mailReturnCode mRet
mailMessage mMsg
mailFileDescription mAttach

//mMsg.Recipient[1].Address = 'paulericmurray@hotmail.com'
mMsg.Recipient[1].name = 'paulericmurray@hotmail.com'
mMsg.Recipient[1].RecipientType = mailTo!
//mMsg.Recipient[2].Address = 'pemurray@groundtravel.com'
mMsg.Recipient[2].name = 'pemurray@groundtravel.com'
mMsg.Recipient[2].RecipientType      = mailCC!

mAttach.Filename = 'Apollo.doc'
mAttach.Pathname = 'T:\Apollo.doc'
mAttach.FileType = mailAttach!
//mAttach.Position = 1

mMsg.Subject = 'Test Message'
mMsg.NoteText = 'This is the body of mail ~nAuto Generated E-mail by the system'


// Create a mail session
mSes = CREATE mailSession
// Log on to the session
//mRet = mSes.mailLogon(mailNewSession!)

mRet = mSes.mailLogon()
IF mRet <> mailReturnSuccess! THEN
     MessageBox("Mail", 'Logon failed.')
     RETURN
END IF

mMsg.AttachmentFile[1] = mAttach
IF mRet <> mailReturnSuccess! THEN
     MessageBox("Mail", 'Attachment failed.')
     RETURN
END IF


mRet = mSes.mailAddress(mMsg)
IF mRet <> mailReturnSuccess! THEN
     MessageBox("Mail", 'Addressing failed.')
     RETURN
END IF

// Send the mail
mRet = mSes.mailSend(mMsg)
IF mRet <> mailReturnSuccess! THEN
     MessageBox("Mail", 'Sending mail failed.')
        MessageBox("Mail", String(mRet))

string mailreturnstring
        
        mailreturnstring = MailErrorToString(mRet)
        MessageBox("Email Result", "Email ReturnCode = " + mailreturnstring)
     RETURN
END IF

mSes.mailLogoff()
DESTROY mSes


Thank you in advance for your help.

Paul
ASKER CERTIFIED SOLUTION
Avatar of falvaro3
falvaro3

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of falvaro3
falvaro3

whoopsie.  my bad.  I was using the Recipient object from the Outlook object model (which contains the Resolve() method to resolve addresses from the address book).  Sorry about that (unless, of course, you'd want to do it that way... ;).
There is, however, a mailResolveRecipient() PowerScript method of the mailSession object in Powerbuilder which resolves usernames.  Not sure if it resolves qualified addresses, though.
I would lean toward my 8/30/2004 comment as a possible suggestion for a solution, since the code was dealing with the mailSession object in PB, and the mailResolveRecipient() is a valid method of that object.
I would like to hear from the original poster first, of course.
10-q, fa
Avatar of pemurray

ASKER

Sorry, I was sure that I tried that but I will check it out again tonight.  Thank you, Paul