Hello,
I am using PowerBuilder 11.5, attempting to send a simple message to prove out the process. The steps appear to be straight-forward to me but the mail send always fails. There are two behaviors that may be clues to the problem. I have listed them and a code snippet (edited to not include actual email addresses) below.
The two odd behaviors are:
1) For the statement (from snippet): <ml_msg.recipient[1].address = "someone@someplace.com">, if the address is valid and is entered in the standard format <x@y.com>, the outlook address book pops up. If I preceed the address with a colon <":someone@someplace.com"> the address book does not pop up. Does this symptom indicate some kind of problem establishing the address? I have tried multiple variations for entering the address with no success.
2) The statement <ml_rtn = iml_sesn.mailsend( )> fails with "mailreturnfailure!” even though the "ml_msg" structure appears to be set up correctly. I have tried several variations and searched the web but I cannot get this last bit to work. We are using MAPI to extract attachments from received mail so I know the MAPI service is functioning.
The mailrecipient property contains one entry. It seems correct to me and looks like this:
===============
[] mailrecipient [1]
<> blob entryid
<> mailrecipienttype recipienttype = mailto!
<> powerobject classdefinition
<> string address = "someone@someplace.com"
<> string name = "NameOfTheRecipient"
===============
Thanks for your time and your help...
==== Code Begin ===
MailMessage ml_msg
MailReturnCode ml_rtn
string ls_msg = ""
// instantiate the mail session object and perform one-time operations
If Not IsValid(iml_sesn) Then
iml_sesn = Create MailSession
// log onto mail
ml_rtn = iml_sesn.maillogon(mailNewSession!)
// was the logon successful?
if ml_rtn = mailReturnSuccess! Then
ib_logonsuccessful = True
// set some of the mail properties
ml_msg.subject = "Test MAPI Send"
ml_msg.recipient[1].address = "someone@someplace.com"
ml_msg.recipient[1].Name = "NameOfTheRecipient"
Else
// construct part of user error message
If ml_rtn = mailReturnLoginFailure! Then
ls_msg = "The mail service indicates that a mail login failure occured."
Elseif ml_rtn = mailReturnInsufficientMemory! Then
ls_msg = "The mail service has indicated that there was insufficient memory to complete the login."
Elseif ml_rtn = mailreturntooManySessions! Then
ls_msg = "The mail service has indicated that there are too many sessions open to complete the login."
End If
End If
End If
// if the program could not log on successfully, notify the user. But only do it once.
If not ib_logonsuccessful and not ib_logonfailmsgsenttouser Then
// make sure another message is not sent
ib_logonfailmsgsenttouser = true
// notify the user that their mail connection did not succeed
If ls_msg <> "" Then
// there is a clarifying message, attach it to the generic failure message
ls_msg = "The program failed to connect to the mail service. ~n~n" + ls_msg
Else
ls_msg = "The program failed to connect to the mail service."
End If
Messagebox("Mail Connection Failure",ls_msg,Exclamation!)
End If
// do not do any further processing if the logon failed
If not ib_logonsuccessful Then Return
// build the message
ml_msg.notetext="A simple test of mail functionality."
// update the session with current information
iml_sesn.mailaddress( ml_msg)
// send the message
ml_rtn = iml_sesn.mailsend( )
====== Code End ====
I am using PowerBuilder 11.5, attempting to send a simple message to prove out the process. The steps appear to be straight-forward to me but the mail send always fails. There are two behaviors that may be clues to the problem. I have listed them and a code snippet (edited to not include actual email addresses) below.
The two odd behaviors are:
1) For the statement (from snippet): <ml_msg.recipient[1].address = "someone@someplace.com">, if the address is valid and is entered in the standard format <x@y.com>, the outlook address book pops up. If I preceed the address with a colon <":someone@someplace.com"> the address book does not pop up. Does this symptom indicate some kind of problem establishing the address? I have tried multiple variations for entering the address with no success.
2) The statement <ml_rtn = iml_sesn.mailsend( )> fails with "mailreturnfailure!” even though the "ml_msg" structure appears to be set up correctly. I have tried several variations and searched the web but I cannot get this last bit to work. We are using MAPI to extract attachments from received mail so I know the MAPI service is functioning.
The mailrecipient property contains one entry. It seems correct to me and looks like this:
===============
[] mailrecipient [1]
<> blob entryid
<> mailrecipienttype recipienttype = mailto!
<> powerobject classdefinition
<> string address = "someone@someplace.com"
<> string name = "NameOfTheRecipient"
===============
Thanks for your time and your help...
==== Code Begin ===
MailMessage ml_msg
MailReturnCode ml_rtn
string ls_msg = ""
// instantiate the mail session object and perform one-time operations
If Not IsValid(iml_sesn) Then
iml_sesn = Create MailSession
// log onto mail
ml_rtn = iml_sesn.maillogon(mailNewSession!)
// was the logon successful?
if ml_rtn = mailReturnSuccess! Then
ib_logonsuccessful = True
// set some of the mail properties
ml_msg.subject = "Test MAPI Send"
ml_msg.recipient[1].address = "someone@someplace.com"
ml_msg.recipient[1].Name = "NameOfTheRecipient"
Else
// construct part of user error message
If ml_rtn = mailReturnLoginFailure! Then
ls_msg = "The mail service indicates that a mail login failure occured."
Elseif ml_rtn = mailReturnInsufficientMemory! Then
ls_msg = "The mail service has indicated that there was insufficient memory to complete the login."
Elseif ml_rtn = mailreturntooManySessions! Then
ls_msg = "The mail service has indicated that there are too many sessions open to complete the login."
End If
End If
End If
// if the program could not log on successfully, notify the user. But only do it once.
If not ib_logonsuccessful and not ib_logonfailmsgsenttouser Then
// make sure another message is not sent
ib_logonfailmsgsenttouser = true
// notify the user that their mail connection did not succeed
If ls_msg <> "" Then
// there is a clarifying message, attach it to the generic failure message
ls_msg = "The program failed to connect to the mail service. ~n~n" + ls_msg
Else
ls_msg = "The program failed to connect to the mail service."
End If
Messagebox("Mail Connection Failure",ls_msg,Exclamation!)
End If
// do not do any further processing if the logon failed
If not ib_logonsuccessful Then Return
// build the message
ml_msg.notetext="A simple test of mail functionality."
// update the session with current information
iml_sesn.mailaddress( ml_msg)
// send the message
ml_rtn = iml_sesn.mailsend( )
====== Code End ====