We have an application developed in Centura/Team Developer 6. We will migrate to a newer version, but for now we are still developing features for version 6. A new feature was requested to send an email after the user performs a certain action. Is it possible to send email via SMTP on TD?
We use office365 to send email in applications written in another language. Can we use it in TD?
Can someone provide an example?
The docs mention the SalMail class, but we haven’t figured out how to make it work with office365.
We are using the following parameters:
[email protected]
sPassword=<password>
sServerName=smtp.office365.com
nPort=587
bSSL=True
bSend=True
dfSubject="System Notification"
[email protected]
[email protected]
dfCc=Null
mlEmailContent="Test message. Do not reply."
sAttachments=Null
bDeliveryRecipient=Null
nMailPriority=1
Then in the code:
Call oSMTP.SetUser( sUserName, sPassword )
Call oSMTP.SetMailServer(sServerName, nPort, bSSL, bSend)
Set nreturnConnect = oSMTP.Connect()
Set nreturnSendMail = oSMTP.SendMail( nMailFormat, dfSubject,
dfFrom, dfTo, dfCc, mlEmailContent, sAttachments, bDeliveryRecipient,
nMailPriority )
This code should work with office365?
Which values are acepted by nMailFormat?
Note: I’m not a TD developer, I’m just helping the TD team.
Thank you.
It is absolutely possible to send an eMail via SMTP with TD6. Either with an Outlook client ( Office 365 WinAPI ) or SalMail.
If you want a nice easy example in TD6.2 of how to send using Office 365 WinAPI – get it here: Outlook Automation and includes Attachments
But it looks like you’re using SalMail – but can’t really tell from your code, as you haven’t included the declaration of ‘oSMTP’ , nor have you shown the function ‘oSMTP.SendMail’ ( so I don’t know what its doing – it should look something like : Return SmtpSendMail( m_nSmtpObjectAddress, nFormatFlag, sSubject, sOriginator, sRecipientsList, sCarbonCopy, sBody, sAttachments, bReceiptRequested, nFlag )
) inside the ‘oSMTP.SendMail’ function, if it is SalMail. Assuming it is SalMail, you do need to check that your TD app is 32bit or 64bit , as your office 365 in most likely 64 bit – and possibly the problem is they will clash if they don’t match bitness. In theory your code should work, if you set nMailFormat ( which is passed into nFormatFlag in SmtpSendMail() ) to MAIL_FORMAT_PLAIN_TEXT ( value 0 ) and try Port 25 rather than 587.
If you can’t get SalMail to work, its possibly the bitness, so its quick and easy to use the Office 365 API, as per the example above – which does work A-Ok, plus gives you a myriad of other functionality.
What error do you get? Since Microsoft changed the login procedure for Office 365 mailaccounts it could be a problem with the login.