Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Create and Send HTML Mail
This VB6 example program shows how to manually construct and send an HTML mail.
' VB source code to create a simple HTML email and send it.
' This example manually builds the HTML mail.
' (An alternative is to use the Chilkat MHT component in conjunction with
' Chilkat Mail to automate the creation of HTML mail from
' HTML files or Web pages (URLs).)
Private Sub Command1_Click()
' Create a mailman object for sending HTML email
Dim mailman As ChilkatMailMan2
Set mailman = New ChilkatMailMan2
mailman.UnlockComponent "Anything works to start 30-day trial"
' Set the SMTP host.
mailman.SmtpHost = "smtp.comcast.net"
' Only set the username/password if the SMTP server requires it.
'mailman.SmtpUsername = "my_username"
'mailman.SmtpPassword = "my_password"
' Create the email, add content, address it, and sent it.
Dim email As ChilkatEmail2
Set email = New ChilkatEmail2
email.AddTo "Chilkat Admin", "admin@chilkatsoft.com"
email.AddTo "Chilkat Gmail", "chilkat.support@gmail.com"
email.AddTo "Chilkat Yahoo", "chilkat_software@yahoo.com"
email.subject = "This is a test"
imageContentID = email.AddRelatedFile("c:/temp/dude.gif")
email.SetHtmlBody ("<!DOCTYPE HTML PUBLIC " & Chr(34) & _
"-//W3C//DTD HTML 4.0 Transitional//EN" & Chr(34) & _
"><HTML><HEAD></HEAD><BODY>" & _
"<br>This is an example of embedding an image in HTML email.<BR><IMG SRC=" & _
Chr(34) & "cid:" & imageContentID & Chr(34) & _
"><br>(The content ID of the image looks like this: " & _
imageContentID & "<br>The <b>HTML</b> for embedding the image looks like this: <img src=" & _
Chr(34) & "cid:" & imageContentID & Chr(34) & "><br></BODY></HTML>")
email.AddPlainTextAlternativeBody "This is the plain text"
email.From = "support@chilkatsoft.com"
' Call SendEmail to send HTML email.
success = mailman.SendEmail(email)
If (success = 1) Then
MsgBox "Mail Sent!"
Else
MsgBox mailman.LastErrorText
End If
Set email = Nothing
Set mailman = Nothing
End Sub
|
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.