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
|
Send Email with Attachments in Visual FoxPro 7
This example source code demonstrates sending mail with an attachment in Visual FoxPro. ***********************************************************
*** chilkat SMTP: send a single email with attachment
***********************************************************
LOCAL loMailMan, loEmail, lnSuccess, lcFileName
lcFileName = ''
********************************************************************
*!* object loMailman (ChilkatMailMan) manages pop3/smtp configuration
*!* and sending and receiving emails
********************************************************************
*!* object loEMail (ChilkatEmail) represents an email
********************************************************************
****************************
*!* configure smtp options
****************************
loMailman = CreateObject('Chilkat.MailMan2')
loMailman.UnlockComponent('unlock_code') && Unlocks the mailman object
loMailman.SmtpHost = 'smtp.earthlink.net' && The hostname of the SMTP server used to send email
*loMailman.SmtpUsername = 'myLogin' && The login for logging into the SMTP server. Use this only if your SMTP server requires authentication
*loMailman.SmtpPort = 25 && default: 25 -> The port number of the SMTP server used to send email. Only needs to be set if the SMTP server is running on a non-standard port
****************************
*!* create the email
****************************
loEmail = CreateObject("Chilkat.Email2")
loEmail.AddTo ( "Chilkat Support", "support@chilkatsoft.com") && Adds a recipient to the "to" list
loEmail.Body = "This is an email." && The body of the email
loEmail.FromName = 'Matt'
loEmail.FromAddress = "matt@chilkatsoft.com"
*!* Get file name
lcFileName =GETFILE('','','',0,'Select the file to add in the email')
IF .NOT. EMPTY( lcFileName )
loEmail.Subject = "Test e-mail with attachment" && The subject of the email
*!* Add attachment to the email object: AddFileAttachment(fileName As String) As String
loEmail.AddFileAttachment( lcFileName )
ELSE
loEmail.Subject = "Test e-mail without attachment" && The subject of the email
ENDIF
lnSuccess = loMailman.SendEmail(loEmail) && Send an email. If mail was not successfully sent to any recipients, then an error is raised
*!* Nobody got the email: Function returns 0 and error is raised.
*!* Everybody got the email: Function returns 1.
*!* Some, but not everyone, got the email: Function returns 0, but error is not raised.
IF ( lnSuccess = 1 )
=MESSAGEBOX('The mail was sent succesfully',0+64,'Chilkat send email')
ENDIF
******************************************************************************
* Releasing objects
******************************************************************************
RELEASE loMailman, loEmail
RETURN .T.
******************************************************************************
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser