Documentation of the CDO.Message is available at the MSDN:
http://msdn.microsoft.com/en-us/library/ms526453(EXCHG.10).aspx
Powerbuilder didn't like string-indexed collections nor did it work
well with default properties (caused compile errors). So I got it all
ironed out and the following is my code:
And I'm not the king of error handling, it can probably be improved.
I'm just maintaining someone elses horrible mess, I don't regularly
develop in powerbuilder.
///////////////////////// use the CDO.Messsage object (IDispatch) to
send the email
OleObject objMsg
objMsg = CREATE OleObject
TRY
objMsg.ConnectToNewObject("CDO.Message")
objMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/
configuration/sendusing").Value = 2
// Change the name of the mail server in the next line
objMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/
configuration/smtpserver").Value = "mymailserver.domain.com"
objMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/
configuration/smtpauthenticate").Value = 1
// Set the username and password in the next two lines
objMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/
configuration/sendusername").Value = "Username Here!"
objMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/
configuration/sendpassword").Value = "Password Here!"
// The to and the from users go in here.
objMsg.To = "us...@someplace.com"
objMsg.From = "some_other_user@somewhere_else.com"
// For formatted text, instead of TextBody use HTMLBody property,
using HTML code to format it.
objMsg.TextBody = "Example text from powerbuilder using
CDO.Message"
objMsg.Subject = "PBuilder use of CDO.Message"
objMsg.AddAttachment("C:\LabResults\Cow 987.pdf")
objMsg.DSNOptions = 14
objMsg.Configuration.Fields.Update()
objMsg.Send()
CATCH (Exception Ex)
MessageBox("Send Email Failure", "Email failed with the
following error: "+Ex.Text)
return false
END TRY
destroy objMsg
return true