WD20 - using office365 as mailserver

Startbeitrag von Arie am 10.03.2016 11:29

one of my clients uses Office365 as their Exchange server.
The address is something like https://outlook.office365.com/mapi/emsmdb/?MailboxId=xxxxxxxxxxx

Currently my application connects to old-fashion Exchange servers using EmailStartSession()
But with that office365 address it fails with this error: Connection failed: recipient address not found.
Loks like a send-message error, although I am not sending an email yet. Strange...

I also tried EmailStartSMTPSession with no luck.

Can someone tell me how send emails using an Office365 account?


Easiest method is using their rest api


von CCC2 - am 10.03.2016 15:27
Didn't know about the REST API.. That's cool.

Office 365 supports SMTP over SSL so you should be able to use EMailStartSession with the optionSSL in the EmailSessionType variable. I haven't personally done it, but see no reason why it wouldn't work. It would need the user name and password of a licensed mailbox to connect to. This is probably the best option for portability where you want all emails coming from a particular mailbox / address.

Another option would be if the client has Outlook installed, then just use the WD Outlook send functions to send directly from the user's outlook, but then it would be from the user's email address.

Another option would be if they have a static IP and if the Admin of the Office 365 tenant agrees, they could setup a connection from Office 365 to the client site. This is done in Exchange Admin --> Mail Flow --> Connections. And allows unauthenticated SMTP over port 25, but doesn't allow for application portability as IP addresses need coding in Office 365.

Another option would be to forget sending via Office 365 and use a service like mailgun. This solution provides good application portability and is what I use to send notifications and email blasts..

von Davie - am 10.03.2016 20:12
I am connecting to office 365 from my windev application and sending emails so I know it is possible. I don't have my code with me right now so I don't have an example handy but I know that I had to use different settings that I was using with google.

von steve erts - am 11.03.2016 15:21
Mr Black

I need the first option you are talking about, so the emails will be saved in a particular mailbox. But neither options (ssl.tls) seem to work. I used the credentials of my customer and I suspect now they send me wrong info. I will check that again next week.
I prefer using the standard WD mail-functions, because that's 10x faster :-)

Using the rest-api is also an option, but will cost more time.

@Steve: could you spend a few minutes of your time and find that example for me?

And I just saw it's possible to get a 1 month trial, so I will give that a try next week and keep you informed.

von Arie - am 11.03.2016 19:24
Hi Arie,

Here is abbreviated example... Hope it helps.

//I am staring session like this.

sEmailSession is string



//Then I'm building email message using email structure (fill in your own info after =)

Email.NbRecipient =
Email.Subject =
Email.HTML =

//Then sending message

IF EmailSendMessage(sEmailSession) = False THEN


von steve erts - am 15.03.2016 05:07
Hi Steve,

what address do you use for sSMTPServer?

von Arie - am 17.03.2016 13:24
My ISP (British Telecom) uses Office365.
I use the following to send/receive emails

lsEmailSession..Name = 'My email address'
lsEmailSession..Password = 'MyPassword'
lsEmailSession..ServerAddress = "smtp.outlook.com"
lsEmailSession..Port = "587"
lsEmailSession..Option = emailOptionSecuredTLS

emailOptionSecuredTLS equates to 1 when viewed in the debugger

von DerekT - am 17.03.2016 14:18
Arie Mars
Hi Steve,

what address do you use for sSMTPServer?


von steve erts - am 17.03.2016 17:23
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.