Advanced e-mail
Dim objSMTP ' Create mailer component Set objSMTP = CreateObject("MailBee.SMTP") ' Enable logging SMTP session into a file objSMTP.EnableLogging = True objSMTP.LogFilePath = "C:\Temp\smtp_log.txt" objSMTP.ClearLog ' Unlock SMTP component objSMTP.LicenseKey = "put your license key here" ' Set SMTP server name objSMTP.ServerName = "mail.server.com" ' Uncomment the following 3 lines to enable SMTP authentication ' objSMTP.AuthMethod = 2 ' objSMTP.UserName = "jdoe" ' objSMTP.Password = "secret" ' Set "From:", "Reply-To:", "To:", "CC:", "BCC:", "Subject:" fields objSMTP.Message.FromAddr = "John Doe <jdoe@some.com> (Some Company)" objSMTP.Message.ReplyToAddr = "Foo Company Support Team <support@some.com>" objSMTP.Message.ToAddr = "Bill Johnes <bill.johnes@domain1.com>, someone@domain2.com (Another company)" objSMTP.Message.CCAddr = "Management Department <man@some.com> (Some Company), stat@statserver.some.com" objSMTP.Message.BCCAddr = "Big.Brother@secretservice.com, Mr. X <collect_secrets@competitorcompany.com>" objSMTP.Message.Subject = "Complex message" ' Set HTML format of the body objSMTP.Message.BodyFormat = 1 ' Construct HTML body: header from file + main part + footer from file ' Export the header into HTML body objSMTP.Message.ImportBodyText "C:\docs\letter.htm", True ' Append main part to HTML body objSMTP.Message.BodyText = objSMTP.BodyText & "<p>This is main part</p>" ' Export the footer into HTML body. AppendMode is True, ' so exported content will not overwrite existing body objSMTP.Message.ImportBodyText "C:\docs\letter.htm", True, True ' HTML body ready, generate plain-text version objSMTP.Message.MakeAltBody ' Add attachment from the file objSMTP.Message.AddAttachment "C:\My documents\report.xls" ' Add custom header objSMTP.Message.AddHeader "X-Special", "Something" ' Try to send message If objSMTP.Send Then MsgBox "Sent successfully" Else MsgBox "Error #" & objSMTP.ErrCode & ", " & objSMTP.ErrDesc End If
<% Dim objSMTP ' Create mailer component Set objSMTP = Server.CreateObject("MailBee.SMTP") ' Enable logging SMTP session into a file objSMTP.EnableLogging = True objSMTP.LogFilePath = "C:\Temp\smtp_log.txt" objSMTP.ClearLog ' Unlock SMTP component objSMTP.LicenseKey = "put your license key here" ' Set SMTP server name objSMTP.ServerName = "mail.server.com" ' Uncomment the following 3 lines to enable SMTP authentication ' objSMTP.AuthMethod = 2 ' objSMTP.UserName = "jdoe" ' objSMTP.Password = "secret" ' Set "From:", "Reply-To:", "To:", "CC:", "BCC:", "Subject:" fields objSMTP.Message.FromAddr = "John Doe <jdoe@some.com> (Some Company)" objSMTP.Message.ReplyToAddr = "Foo Company Support Team <support@some.com>" objSMTP.Message.ToAddr = "Bill Johnes <bill.johnes@domain1.com>, someone@domain2.com (Another company)" objSMTP.Message.CCAddr = "Management Department <man@some.com> (Some Company), stat@statserver.some.com" objSMTP.Message.BCCAddr = "Big.Brother@secretservice.com, Mr. X <collect_secrets@competitorcompany.com>" objSMTP.Message.Subject = "Complex message" ' Set HTML format of the body objSMTP.Message.BodyFormat = 1 ' Construct HTML body: header from file + main part + footer from file ' Export the header into HTML body objSMTP.Message.ImportBodyText "C:\docs\letter.htm", True ' Append main part to HTML body objSMTP.Message.BodyText = objSMTP.BodyText & "<p>This is main part</p>" ' Export the footer into HTML body. AppendMode is True, ' so exported content will not overwrite existing body objSMTP.Message.ImportBodyText "C:\docs\letter.htm", True, True ' HTML body ready, generate plain-text version objSMTP.Message.MakeAltBody ' Add attachment from the file objSMTP.Message.AddAttachment "C:\My documents\report.xls" ' Add custom header objSMTP.Message.AddHeader "X-Special", "Something" ' Try to send message If objSMTP.Send Then Response.Write "Sent successfully" Else Response.Write "Error #" & objSMTP.ErrCode & ", " & objSMTP.ErrDesc End If %>See Also: