'=======================================================================================
'
' Example 1
'
' Send a text email with attachments.
'
'=======================================================================================
' Create a Chilkat.MailMan object for sending,
' and set the necessary properties and unlock the component.
Dim mailman as New Chilkat.MailMan()
mailman.UnlockComponent(Request.form("unlockCode"))
' Tell the MailMan the SMTP server to be used for sending email.
mailman.SmtpHost = Request.form("smtpServer")
' Optionally provide the SMTP server with a login and password.
' The MailMan will automatically choose the most secure SMTP authorization
' method available.
if Request.form("smtpLogin") <> "" then
mailman.SmtpUsername = Request.form("smtpLogin")
mailman.SmtpPassword = Request.form("smtpPassword")
end if
' Create an Email object. The mailman will send the email.
Dim email As New Chilkat.Email()
' Give our email a subject, recipient, and return address.
email.From = Request.form("fromAddr")
email.AddTo("",Request.form("recipient"))
email.Subject = "Chilkat ASP.NET " + Request.form("exampleSelected")
' Our body is plain text, so give it a simple body:
email.Body = "This is a plain-text email" + vbcrlf + "There should be 2 attachments."
' Add some attachments.
' We could add file attachments by calling AddFileAttachment and providing a filename,
' but we've decided to side-step these issues and instead add an attachment directly
' from memory.
' You could also add a binary data attachment by calling AddDataAttachment.
email.AddStringAttachment("hello1.txt","Hello, this is text attachment #1")
email.AddStringAttachment("hello2.txt","Hello, this is text attachment #2")
' Connect to the SMTP server and send mail.
if (mailman.SendEmail(email)) then
Response.write("Mail sent!")
else
Response.write("Errors in sending email!")
Response.write(mailman.LastErrorHtml)
end if
|