AddAttachment Method


Attaches a file to the message.

Attached files are automatically base64-encoded to comply with MIME requirements. This method can also handle inline objects (such as images) related in message body. However, you can use ImportBodyText method to let MailBee handle all inline objects itself.


blnResult = ObjectName.AddAttachment(FilePath, [ContentType], [ContentID], [FilenameInMessage])  
Parameters:  
FilePath As String The path to the file being attached  
ContentType As String (optional) If you already know Content-Type of the file, you may specify it. If this parameter is omitted, Content-Type is taken from filename extension  
ContentID As String (optional) Non-empty value denotes that the file is related in message body with specified Content-ID (i.e. inline object). Omitted or empty value denotes ordinary attachment (not inline object). Inline objects are usually not displayed by email clients in attachment lists.  
FilenameInMessage As String (optional) If the value is non-empty, it will be used in the message as attachment filename. For example, you have disk file "C:\Data\abc.tmp" and want to add it to the message as file "graph.gif". To do this, specify FilenameInMessage="graph.gif". If FilenameInMessage is missing or empty, filename extracted from FilePath parameter will be used. If FilenameInMessage="<none>" (angle brackets are important), no filename will be assigned at all (useful when forwarding e-mail messages as attachment).  
Return value As Boolean True if successful, False if error has occurred  

Usage example:

Dim Mailer
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.SMTP")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.SMTP")
'In ASP use Response.Write instead of MsgBox
Mailer.LicenseKey = "put your license key here"
Mailer.ServerName = "mail.server.com"
If Mailer.Connect Then
  Mailer.Message.ToAddr = "bill@yoursite.com"
  Mailer.Message.FromAddr = "joe@mysite.com"
  Mailer.Message.Subject = "Hello"
  Mailer.Message.ImportBodyText "C:\docs\letter.htm", True
  Mailer.Message.AddAttachment "C:\docs\archive.zip"
  Mailer.Message.AddAttachment "C:\docs\picture.tmp", "image/gif","hello.gif", "hello.gif"
  Mailer.Send
  Mailer.Disconnect
End If

See Also:

ImportBodyText Method
EncodeHeaderText Method
AddMemoryAttachment Method
BodyText Property
AltBodyText Property


Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.