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
Load MIME (or S/MIME) and Send as EmailDemonstrates how to load a MIME file and send it as email.
Dim mime As New Chilkat.Mime() Dim mailman As New Chilkat.MailMan() ' Any string argument automatically begins the 30-day trial. Dim success As Boolean success = mime.UnlockComponent("30-day trial") If (success <> true) Then MsgBox(mime.LastErrorText) Exit Sub End If ' Any string argument automatically begins the 30-day trial. success = mailman.UnlockComponent("30-day trial") If (success <> true) Then MsgBox(mailman.LastErrorText) Exit Sub End If ' Set the SMTP server. mailman.SmtpHost = "smtp.chilkatsoft.com" ' Set the SMTP login/password (if required) mailman.SmtpUsername = "myUsername" mailman.SmtpPassword = "myPassword" ' Load the MIME (or S/MIME) from a file: success = mime.LoadMimeFile("edifact_smime.txt") If (success <> true) Then MsgBox(mime.LastErrorText) Exit Sub End If Dim fromAddr As String Dim recipient As String fromAddr = "admin@chilkatsoft.com" recipient = "support@chilkatsoft.com" ' Add email header fields to the MIME: mime.AddHeaderField("From",fromAddr) mime.AddHeaderField("To",recipient) mime.AddHeaderField("Subject","Here is my EDIFACT signed and encrypted...") ' We want a Date header with the current date/time. The email object ' automatically generates it. Therefore we'll create an email object and then ' copy the Date header: Dim email As New Chilkat.Email() Dim dateStr As String dateStr = email.GetHeaderField("Date") mime.AddHeaderField("Date",dateStr) ' It is not necessary to save the MIME to a file. ' We're doing it here just to have a look at the .eml in a text editor... success = mime.SaveMime("email.eml") If (success <> true) Then MsgBox(mime.LastErrorText) Exit Sub End If ' Now send the MIME via SMTP: Dim mimeContent As String mimeContent = mime.GetMime() success = mailman.SendMime(fromAddr,recipient,mimeContent) If (success <> true) Then MsgBox(mailman.LastErrorText) Exit Sub End If success = mailman.CloseSmtpConnection() If (success <> true) Then MsgBox("Connection to SMTP server not closed cleanly.") End If MsgBox("Mail Sent!") |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.