简体   繁体   中英

Sending Multipart Email in vbscript

I wrote a script that sends HTML emails. It worked well in Gmail, but I opened it in Outlook, it was all Chinese.

I learned about MIME emails - Sending 2 versions of the email, one with HTML and one plain text, but didn't understand how to create one. I saw somewhere that you need a certificate with a private key.

Can someone explain how to make it work?

This is my email-sending code:

'Send an email
strSMTPFrom = "Test@hp.com"
strSMTPTo = email             'Email taken from array
strSMTPRelay = "smtp1.hp.com"       
strTextBody = strContent      'Content taken from the template

Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
oMessage.Configuration.Fields.Update

oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.HTMLBody = strTextBody
oMessage.Send

Found the answer. It was the charset. The HTML had this in one of the tags. The charset was set to Unicode . When it came to the Email clients, it was changed to UTF-8 . Gmail was able to make it work but Outlook wasn't.

We sent an HTML email example we found online, and when we saw it worked we checked its charset, which was windows-1255 .

We changed the tag in our code and it worked!

Thank you once again though for the quick reply

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM