Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Send mail code VBS 2 QM
#1
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.

 
Code:
Copy      Help
 
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") = "xxx@126.com" '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 "xxx@126.com", "aaa@outlook.com", "bbb@outlook.com", "Test mail", "take action"


Forum Jump:


Users browsing this thread: 1 Guest(s)