Hi All,
I'm hoping someone has experience with Chilkat I'm currently just running the 30 day trial to see if it can do what I want it to.
My company is moving from a dedicated mail server on site to Office 365, a number of our current Foxpro forms automatically generate an email for our end customer using Westwind Utils and it works great but I cannot figure out how to use WW for 365 and so am trialling Chilkat.
This is the current code I am running to try and send an email with an attachment I am receiving the email just without the file attached I'm hoping someone can point me in the right direction.
Cheers,
Babs.
I'm hoping someone has experience with Chilkat I'm currently just running the 30 day trial to see if it can do what I want it to.
My company is moving from a dedicated mail server on site to Office 365, a number of our current Foxpro forms automatically generate an email for our end customer using Westwind Utils and it works great but I cannot figure out how to use WW for 365 and so am trialling Chilkat.
Code:
LOCAL loJsonToken
LOCAL lnSuccess
LOCAL loMailman
LOCAL loEmail
LOCAL loAttach1
SET DEFAULT TO "T:\WIPTRACK\Chilkat"
* First get our previously obtained OAuth2 access token.
loJsonToken = CreateObject('Chilkat_9_5_0.JsonObject')
lnSuccess = loJsonToken.LoadFile("t:\wiptrack\chilkat\token\office365.json")
loMailman = CreateObject('Chilkat_9_5_0.MailMan')
loMailman.SmtpHost = "smtp.office365.com"
loMailman.SmtpPort = 587
loMailman.StartTLS = 1
* Use your Office365 email address for the SmtpUsername.
loMailman.SmtpUsername = "it@DOMAIN.onmicrosoft.com"
loMailman.OAuth2AccessToken = loJsonToken.StringOf("access_token")
* Create a new email object
loEmail = CreateObject('Chilkat_9_5_0.Email')
loAttach1 = CreateObject('Chilkat_9_5_0.BinData')
loAttach1.LoadFile("C:\1\c2v.txt")
loEmail.Subject = "This is sent via chilkat in vfp"
loEmail.Body = "This is a test"
loEmail.From = "IT <it@DOMAIN.onmicrosoft.com>"
lnSuccess = loEmail.AddTo("Testing email","babs23@DOMAIN.co.uk")
lnSuccess = loMailman.SendEmail(loEmail)
IF (lnSuccess <> 1) THEN
thisform.edit1.Value= loMailman.LastErrorText &&debug purposes
RELEASE loJsonToken
RELEASE loMailman
RELEASE loEmail
CANCEL
ENDIF
lnSuccess = loMailman.CloseSmtpConnection()
IF (lnSuccess <> 1) THEN
thisform.Label1.Caption= "Connection to SMTP server not closed cleanly."
ELSE
thisform.Label1.Caption= "Mail Sent!"
ENDIF
RELEASE loJsonToken
RELEASE loMailman
RELEASE loEmail
This is the current code I am running to try and send an email with an attachment I am receiving the email just without the file attached I'm hoping someone can point me in the right direction.
Cheers,
Babs.