tfinding
asked on
Use IIS to relay SMTP email within a VB Script
Hello
We currently have a VB Script (attached) that runs against certain clients & checks servers & services. It then sends an email via the client's Exchange server.
Recently one of our client's has started to use Office365, so they no longer need Exchange. Therefore, I need to amend the script to send the email via SMTP and IIS.
I have configured IIS & SMTP to send externally - this works with a backup application that sends Job alerts, so I just need to amend the script accordingly.
Thanking you in advance.
BCC.txt
We currently have a VB Script (attached) that runs against certain clients & checks servers & services. It then sends an email via the client's Exchange server.
Recently one of our client's has started to use Office365, so they no longer need Exchange. Therefore, I need to amend the script to send the email via SMTP and IIS.
I have configured IIS & SMTP to send externally - this works with a backup application that sends Job alerts, so I just need to amend the script accordingly.
Thanking you in advance.
BCC.txt
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Scott - sorry for the delay
I changed it thus;
strSMTPServer = "smtp.office365.com"
strFrom = "Client Name <administrator@client-name .onmicroso ft.com>"
With objMsg.Configuration.Field s
sch = "http://schemas.microsoft.com/cdo/configuration/"
.Item (sch & "sendusing") = 2
.Item (sch & "smtpserver") = strSMTPServer
.Item (sch & "smtpserverport") = 587
.Item (sch & "sendusername") = "administrator@client-name .onmicroso ft.com"
.Item (sch & "sendpassword") = "password"
.Item (sch & "sendusessl") = 1
.Item (sch & "sendauthenticate") = 1
.Update
End With
It ends with a Windows Script Host error on the line which states : objMsg.Send;
Error : The transport failed to connect to the server
Code : 80040213
Source : CDO.Message.1
Many thanks again
I changed it thus;
strSMTPServer = "smtp.office365.com"
strFrom = "Client Name <administrator@client-name
With objMsg.Configuration.Field
sch = "http://schemas.microsoft.com/cdo/configuration/"
.Item (sch & "sendusing") = 2
.Item (sch & "smtpserver") = strSMTPServer
.Item (sch & "smtpserverport") = 587
.Item (sch & "sendusername") = "administrator@client-name
.Item (sch & "sendpassword") = "password"
.Item (sch & "sendusessl") = 1
.Item (sch & "sendauthenticate") = 1
.Update
End With
It ends with a Windows Script Host error on the line which states : objMsg.Send;
Error : The transport failed to connect to the server
Code : 80040213
Source : CDO.Message.1
Many thanks again
Are you sure you have authorized remote for this account?
ASKER
Hi Scott
Yes, because I am sending the backup job alerts through smtp.office365.com.
Yes, because I am sending the backup job alerts through smtp.office365.com.
I had a client that used to use office365 and I had this working with cdo. I will hunt around to see if I can find the code I used.
ASKER
Many thanks.
As an aside, if I create a .txt file with a recipient/sender address into the Inetpub\mailroot\pickup folder, this is delivered to the recipient without issue.
Therefore, the SMTP virtual server within IIS 6.0 is ok. Again, it's using smtp.office365.com as the smart host for the routed domain.
As an aside, if I create a .txt file with a recipient/sender address into the Inetpub\mailroot\pickup folder, this is delivered to the recipient without issue.
Therefore, the SMTP virtual server within IIS 6.0 is ok. Again, it's using smtp.office365.com as the smart host for the routed domain.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Had to play around with the script & the SMTP Virtual server to get this working - all contributions allowed me to pursue & check all settings.
Make sure you are using the correct the correct smtp server. Instead of the ip, strSMTPServer should be set to smtp.office365.com port 587 and you will need authentication
https://support.office.com/en-au/article/Settings-for-POP-and-IMAP-access-for-Office-365-for-business-or-Microsoft-Exchange-accounts-7fc677eb-2491-4cbc-8153-8e7113525f6c
https://social.msdn.microsoft.com/Forums/en-US/71d50521-3e19-4ae3-a455-ebbf5375be35/sending-mails-thru-microsoft-office-365?forum=visualfoxprogeneral