AddStringAttachment Method


Creates an attachment from text string and attaches it to the message.

Attached files are automatically encoded to base64 encoding to comply with MIME requirements. This method can also handle inline objects (such as images) related to the message body.


blnResult = ObjectName.AddStringAttachment(Data, AsUTF8, FilenameInMessage, [ContentType], [ContentID])  
Parameters:  
Data As String Attachment text data represented as String.  
AsUTF8 As Boolean If this parameter contains true the string automatically converts to UTF-8 encoding. Otherwise, the default operational system encoding is used.  
FilenameInMessage As String Specifies the file name of the attachment in message. For example, if you have file "C:\Data\abc.tmp" and want to add it to the message as file "graph.gif", you just need to specify FilenameInMessage as "graph.gif".  
ContentType As String (optional) Specifies the Content-Type of file if it's already known. If this parameter is empty or ommited, Content-Type is taken from filename extension.  
ContentID As String (optional) Non-empty value denotes that the file is related tomessage body with specified Content-ID (i.e. inline object). Omitted or empty value designates ordinary attachment (not inline object). Inline objects are usually not displayed by email clients in attachment lists.  
Return value As Boolean True if successful, False if error has occurred  
Remarks: If the message was received through MailBee.POP3 object, this method will do nothing unless Message.Locked property is set to False.

Usage example:

<%
' This sample attaches text string as text file to the message without creating any temporary files

Dim Mailer, Uploader, File

' Using ASP to create the object
Set Mailer = Server.CreateObject("MailBee.SMTP")

' Using Visual Basic to create the object
'Set Mailer = CreateObject("MailBee.SMTP")

' Specify MailBee license key
Mailer.LicenseKey = "put your license key here"

' Specify the name of the mail server
Mailer.ServerName = "mail.server.com"

' Connect to the specified mail server
If Mailer.Connect Then
	' Load the message from file
	Mailer.Message.ImportFromFile("c:\letter.eml")

	' Add the attachment from string
	Mailer.Message.AddStringAttachment "This is attachment body", False, "sample.txt", "text/plain"

	' Send the message
	Mailer.Send

	' Disconnect from the mail server
	Mailer.Disconnect
End If
%>

See Also:

AddAttachment Method, Uploader Object


Copyright 2002-2008, AfterLogic Corporation. All rights reserved.