MAPISetAttachment

Syntax

MAPISetAttachment(FileName$, PathName$, Position, Flags, Reserved)

Remarks

Attaches a file to the current outbound message. A message can include multiple attachments. MAPISetAttachment attaches Word documents or any other data file, but the function does not support OLE objects.

Errors in attachment processing are not returned until the message is actually sent with MAPISendMail.

Argument

Explanation

FileName$

The filename seen by the recipient. This name can differ from the filename in PathName$. If FileName$ is empty, the filename from PathName$ is used.

PathName$

The full path of the file to be attached.

Position

An integer indicating where the attachment is placed in the message body. The first position is 0 (zero), and the last position is the length of the note text minus 1. The file attachment overwrites the existing character in its position.

Use –1 for Position to insert the attachment at the beginning of the message without overwriting an existing character.

Flags

Reserved for future use. This argument must be 0 (zero).

Reserved

Reserved for future use. This argument must be 0 (zero).


Example

This example attaches two files to the current outbound message, then sends the message. One file is attached at the beginning of the message, the other at the end.


Sub MAIN
MAPI_LOGON_UI = 1
Session = MAPILogon(0, "", "", MAPI_LOGON_UI, 0)
Dim NoteText$
NoteText$ = "We will quickly satisfy all orders for clamps. "
result = MAPISetRecipient(1, "Phillipe Tran", "AF:TBU/WGAM/PHILT")
result = MAPISetRecipient(2, "Patricia Loren", "AF:TBU/WGAM/PATL")
result = MAPISetAttachment("THANKYOU.DOC", "C:\DOCUMENT\THANKYOU.DOC",\
    - 1, 0, 0)
result = MAPISetAttachment("CONTRACT.DOC", "C:\WGTPLATE\CONTRACT.DOC",\
    Len(NoteText$) - 1, 0, 0)
result = MAPISendMail(Session, 0, "Monthly Summary", NoteText$, 0, 0)
result = MAPILogoff(Session, 0, 0, 0)
End Sub