Как отправить письмо из VBS скрипта? Легко.
- Кодировка ANSI
Без аутентификации:
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "test@domain.ru"
emailObj.To = "vpupkin@gmail.com"
emailObj.Subject = "Тестовый заголовок"
emailObj.TextBody = "Текст на кириллице"
emailObj.BodyPart.CharSet = "windows-1251"
Set emailConfig = emailObj.Configuration
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smpt.mail.server"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = false
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/languagecode") = 1049
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/usemessageresponsetext") = true
emailConfig.Fields.Update
emailObj.Send
If err.number = 0 then Msgbox "Done"
С аутентификацией:
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "test@domain.ru"
emailObj.To = "vpupkin@gmail.com"
emailObj.Subject = "Тестовый заголовок"
emailObj.TextBody = "Текст на кириллице"
Set emailConfig = emailObj.Configuration
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smpt.mail.server"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "логин"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "пароль"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = false
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/languagecode") = 1049
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/usemessageresponsetext") = true
emailConfig.Fields.Update
emailObj.Send
If err.number = 0 then Msgbox "Done"