Name
AttachFile —
objNewMail
.AttachFile (
strSource
[,
strFileName
]
[,
lngEncodingSetting
] )
Synopsis
Embeds an attachment from a file into a mail message.
Parameters
-
strSource
A string containing the pathname and filename of the file to embed
-
strFileName
A string containing the name that will be displayed in the mail message to represent the embedded attachment
-
lngEncodingSetting
A Long that can contain either of the following CDO constants:
-
CdoEncodingUUEncode (0)
The attachment you embed in your message will be encoded in the UUEncode format. This is the default value.
-
cdoEncodingBase64 (1)
The attachment you embed in your message will be encoded in the base 64 format.
-
Example
<% ' Dimension local variables. Dim objNewMail Dim strRecipList ' Instantiate a NewMail object. Set objNewMail = Server.CreateObject("CDONTS.NewMail") ' Set the body string for the message. objNewMail.Body = _ "Wow, this message takes just a few lines of code." ' Attach a file in the current message. objNewMail.AttachFile "c:\Data\Proposal.doc", _ "Proposal.Doc", cdoEncodingBase64 ' Send the message. For details about the Send method, ' see that section in this chapter. objNewMail.Send "me@here.com","you@there.com", _ "This is the subject",,cdoHigh %>
Notes
If you set the MailFormat property of the NewMail object, you do not
have to include a lngEncodingSetting
parameter in your call to the AttachFile method.
Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.