MailPutAttachment

The MailPutAttachment function adds or change an attachment to a mail message.

Syntax

BOOL MailPutAttachment (HANDLE hMail, MailMsg * pmm, MailAtt * pma);

At a Glance

Header file: Msgstore.h
Platforms: H/PC
Versions: 2.0 and later

Parameters

hMail
Handle to the current mail context. This handle is created by the MailOpen function.
pmm
Pointer to the mail message structure to which the attachment is to be added. The message must have been written to the object store so that the oid field has been set properly.
pma
Pointer to the mail attachment structure to be added to the message if the attachment identification number, uiAttachmentNumber, is greater than the current number of attachments. Otherwise it points to the new attachment to replace the existing one of the same uiAttachmentNumber value.

Return Values

The function returns TRUE if the attachment is added or changed; FALSE otherwise. In the latter case, the caller is responsible for the disposition of the file. To get extended error information, use MailError or MailErrorMsg.

Remarks

For a local attachment, that is, when szLocalName (a member of the MailAtt structure) is set to a non-NULL value, the MailPutAttachment function stores a local copy of the original file in a special folder which is constructed from the registry entries for the attachment directory.

There can be up to 64 attachments to a message. When a single file is attached more than once, the MailPutAttachment function ensures that every local file has a unique path (szLocalName).

Since a local file gets moved, the local name (szLocalName) supplied to the MailPutAttachment function will be different from its counterpart retrieved from the MailGetAttachment function.

When a user composes a message with a file attached, she may want to make a copy of the attached file. In this case, the application should make a copy of the original before invoking the MailPutAttachment function. It is unwise to assume that the transport service will perform such an operation.