Need the ability to send an email with attachment from Powerbuilder

Hi

I need the ability to send an email with an attachment from Powerbuilder.
Please provide code examples, explaining how I connect to my mail server
from within the Powerbuilder appplication.

Thanks

bl00teredAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

diasroshanCommented:
Hi,

Please see the code to send mail with attachment...

Cheers,
Rosh
mailSession mSes
 
mailReturnCode mRet
mailMessage mMsg
mailFileDescription mAttach
 
mMsg.Recipient[1].name = 'abc@hotmail.com'
mMsg.Recipient[1].RecipientType = mailTo!
mMsg.Recipient[2].name = 'xyz@diasroshan.com'
mMsg.Recipient[2].RecipientType      = mailCC!
 
mAttach.Filename = Soccer.doc'
mAttach.Pathname = 'T:\Soccer.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

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.