04-06-2019, 10:02 PM
I found a VBS code on the Internet that doesn't use mail components. How do I convert it to QM code?
I tried to package the mailbee component into the exe file, but always prompted an error. I hope someone can help me use the QM code to implement the VBS email function. Thanks in advance.
I tried to package the mailbee component into the exe file, but always prompted an error. I hope someone can help me use the QM code to implement the VBS email function. Thanks in advance.
function sendEmail(strEmail_From, strEmail_To, strCC_List, strEmail_Subject, strEmail_Body)
Set cdoMail = CreateObject("CDO.Message") 'Create a CDO object
Set cdoConf = CreateObject("CDO.Configuration") 'Create a CDO profile object
cdoMail.From = strEmail_From
cdoMail.To = strEmail_To
cdoMail.CC = strCC_List
cdoMail.Subject = strEmail_Subject
'Message body
cdoMail.HTMLbody = strEmail_Body & "</table></body></html>"
cdoConf.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Use an SMTP server on the network instead of a local SMTP server
'cdoConf.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "9.56.224.215"
cdoConf.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.126.com" 'SMTP server address, can be replaced with other mailbox server or ip you want to use
cdoConf.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'Mail server port
cdoConf.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'Server authentication method
cdoConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]" 'Sender account
cdoConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "123456" 'Sender login email password
cdoConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 'Timeout period for connecting to the server
cdoConf.Fields.Update
Set cdoMail.Configuration = cdoConf
'Set the importance and priority of the message
cdoMail.Fields.Item("urn:schemas:mailheader:X-MSMail-Priority") = "High"
cdoMail.Fields.Item("urn:schemas:mailheader:X-Priority") = 2
cdoMail.Fields.Item("urn:schemas:httpmail:importance") = 2
cdoMail.Fields.Update
'send email
dim sleepSeconds
sleepSeconds = 5
cdoMail.Send
WScript.Sleep(1000 * sleepSeconds)
Set cdoMail = nothing
Set cdoConf = nothing
End function
sendEmail "[email protected]", "[email protected]", "[email protected]", "Test mail", "take action"