Sending Multiple Attachments Via Outlook / Powerbuilder

Posted on 2004-08-27
Last Modified: 2013-12-26
Hi All,

I have succeeded in getting Powerbuilder to send an attachment but I would like to be able to send more than one attachment and am hoping to get an example of how it is done.

Here is my current code:

mailSession mSes

mailReturnCode mRet
mailMessage mMsg
mailFileDescription mAttach

mMsg.Recipient[1].name = ''
mMsg.Recipient[1].RecipientType = mailTo!
mMsg.Recipient[2].name = ''
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.')

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

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

// 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)


Thank you,

Question by:pemurray
LVL 33

Accepted Solution

sajuks earned 500 total points
ID: 11920068
//Try this eg:
mailsession lms_sess
mailmessage lm_mess
mailrecipient lm_recipient
mailFileDescription lmf_file
mailreturncode lmc_rc

lmf_file.FileType = mailAttach!
lmf_file.FileName = "212.txt"
lmf_file.PathName = "c:\" + "212.txt"

lm_mess.NoteText = "this my report."
lm_mess.Subject = "report "
lmf_file.Position = 1
lm_mess.Attachmentfile[1] = lmf_file

lmf_file.FileType = mailAttach!
lmf_file.FileName = "jsp.txt"
lmf_file.PathName = "c:\" + "jsp.txt"
lmf_file.Position = 2
lm_mess.Attachmentfile[2] = lmf_file

lm_recipient.Address = ""
lm_recipient.Name = "My Name"
lm_recipient.RecipientType = mailTo!
lm_mess.Recipient[1] = lm_recipient

lms_sess = create mailsession
lmc_rc = lms_sess.mailLogon()
lmc_rc = lms_sess.mailSend(lm_mess)
IF lmc_rc <> mailReturnSuccess! THEN
        MessageBox("Error", "Error on Send")

lmc_rc = lms_sess.mailLogoff()
DESTROY lms_sess



Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Eclipse versons - run configurations 2 85
PHPStorm, PHPUnit not found in include path 2 379
eclipse formatting 6 72
oracle 11g 23 49
In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now