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.
LOCAL loMime LOCAL loMailman LOCAL lnSuccess LOCAL lcFromAddr LOCAL lcRecipient LOCAL loEmail LOCAL lcDateStr LOCAL lcMimeContent loMime = CreateObject('Chilkat.Mime') loMailman = CreateObject('Chilkat.MailMan2') * Any string argument automatically begins the 30-day trial. lnSuccess = loMime.UnlockComponent("30-day trial") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF * Any string argument automatically begins the 30-day trial. lnSuccess = loMailman.UnlockComponent("30-day trial") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loMailman.LastErrorText) QUIT ENDIF * Set the SMTP server. loMailman.SmtpHost = "smtp.chilkatsoft.com" * Set the SMTP login/password (if required) loMailman.SmtpUsername = "myUsername" loMailman.SmtpPassword = "myPassword" * Load the MIME (or S/MIME) from a file: lnSuccess = loMime.LoadMimeFile("edifact_smime.txt") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF lcFromAddr = "admin@chilkatsoft.com" lcRecipient = "support@chilkatsoft.com" * Add email header fields to the MIME: loMime.AddHeaderField("From",lcFromAddr) loMime.AddHeaderField("To",lcRecipient) loMime.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: loEmail = CreateObject('Chilkat.Email2') lcDateStr = loEmail.GetHeaderField("Date") loMime.AddHeaderField("Date",lcDateStr) * 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... lnSuccess = loMime.SaveMime("email.eml") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF * Now send the MIME via SMTP: lcMimeContent = loMime.GetMime() lnSuccess = loMailman.SendMime(lcFromAddr,lcRecipient,lcMimeContent) IF (lnSuccess <> 1) THEN =MESSAGEBOX(loMailman.LastErrorText) QUIT ENDIF lnSuccess = loMailman.CloseSmtpConnection() IF (lnSuccess <> 1) THEN =MESSAGEBOX("Connection to SMTP server not closed cleanly.") ENDIF =MESSAGEBOX("Mail Sent!") |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser