Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Attach Message to Email (message/rfc822)How to create an email with an attached message (content-type = message/rfc822)
CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @email int EXEC @hr = sp_OACreate 'Chilkat.Email2', @email OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OASetProperty @email, 'Subject', 'Subject...' EXEC sp_OASetProperty @email, 'From', 'Chilkat Support <support@chilkatsoft.com>' -- Call AddTo multiple times, once per recipient, or -- call AddMultipleTo with a comma-separated email address string. -- or call AddHeaderField("To","To someone...") EXEC sp_OAMethod @email, 'AddTo', NULL, 'Chilkat Admin', 'admin@chilkatsoft.com' -- Add our own custom header. EXEC sp_OAMethod @email, 'AddHeaderField', NULL, 'X-MyCompany', 'testing' EXEC sp_OASetProperty @email, 'Body', 'This is the email body...' -- The email object now has a very basic plain-text email, -- with a customer header. -- The email we'll add is going to be loaded from a .eml file: DECLARE @success int EXEC sp_OAMethod @email, 'AddFileAttachment2', @success OUT, 'email.eml', 'message/rfc822' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 END ELSE BEGIN EXEC sp_OAMethod @email, 'SaveEml', NULL, 'out.eml' PRINT 'Success!' END END GO |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.