Sending automated email via Office 365 account requires the use of SSL or in some instances you need to use SSL and TLS both enabled on the script.
Below is an example that works fine using Vbscript.
This is useful if you need to automate email messages via Task Scheduler or Windows event attached to this script, when the event is triggered the script will execute the VBS file and send the message.
Modify the message subject, body and of course, the email domain name, user and password.
Open notepad copy and paste the code, save as "filename.vbs"
The quotes are important when doing save as via notepad or else the file will be save as .txt.
Enjoy! Cheers!
'=======================
Dim xstrAll(), strMessage,intupper()
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Send the mail
SentMail
Sub SentMail
strMessage = strMessage & "Your other message..."
strTo= "your.office365@domain_account.com"
strFrom="your.office365@domain_account.com"
strSubject="Automated Alert Message: Server Notification"
strAccountID="your.office365@domain_account.com"
strPassword="Y-our+Complex.Passweird"
strSMTPServer="smtp.office365.com"
SendMail strTo,strFrom,strSubject,strMessage,strAccountID,strPassword,strSMTPServer
End Sub
Function SendMail( strFrom, strSendTo, strSubject, strMessage , strUser, strPassword, strSMTP )
Set oEmail = CreateObject("CDO.Message")
'configure message
With oEmail.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
'.item("http://schemas.microsoft.com/cdo/configuration/StartTLS") = true ===>This commented line maybe necessary in some instances together with "smtpusessl"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.item("http://schemas.microsoft.com/cdo/configuration/sendusername") = strUser
.item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = strPassword
.Update
End With
' build message
With oEmail
.From = strFrom
.To = strSendTo
.Subject = strSubject
.TextBody = strMessage
End With
' send message
On Error Resume Next
oEmail.Send
If Err Then
WScript.Echo "SendMail Failed:" & Err.Description
End If
End Function
'=====================
http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html
Below is an example that works fine using Vbscript.
This is useful if you need to automate email messages via Task Scheduler or Windows event attached to this script, when the event is triggered the script will execute the VBS file and send the message.
Modify the message subject, body and of course, the email domain name, user and password.
Open notepad copy and paste the code, save as "filename.vbs"
The quotes are important when doing save as via notepad or else the file will be save as .txt.
Enjoy! Cheers!
'=======================
Dim xstrAll(), strMessage,intupper()
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Send the mail
SentMail
Sub SentMail
strMessage = strMessage & "Your other message..."
strTo= "your.office365@domain_account.com"
strFrom="your.office365@domain_account.com"
strSubject="Automated Alert Message: Server Notification"
strAccountID="your.office365@domain_account.com"
strPassword="Y-our+Complex.Passweird"
strSMTPServer="smtp.office365.com"
SendMail strTo,strFrom,strSubject,strMessage,strAccountID,strPassword,strSMTPServer
End Sub
Function SendMail( strFrom, strSendTo, strSubject, strMessage , strUser, strPassword, strSMTP )
Set oEmail = CreateObject("CDO.Message")
'configure message
With oEmail.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
'.item("http://schemas.microsoft.com/cdo/configuration/StartTLS") = true ===>This commented line maybe necessary in some instances together with "smtpusessl"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.item("http://schemas.microsoft.com/cdo/configuration/sendusername") = strUser
.item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = strPassword
.Update
End With
' build message
With oEmail
.From = strFrom
.To = strSendTo
.Subject = strSubject
.TextBody = strMessage
End With
' send message
On Error Resume Next
oEmail.Send
If Err Then
WScript.Echo "SendMail Failed:" & Err.Description
End If
End Function
'=====================
Free Android Apps:
Click on links below to find out more:
Multiplication Table for early learners
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
https://play.google.com/store/apps/details?id=com.myrosaryapp
Comments
Post a Comment