AddMailAttachmentData()

Syntax

Result = AddMailAttachmentData(#Mail, Description$, *Buffer, BufferLength [, MimeType$])
Description
Add memory data as an attachment to the mail.

Parameters

#Mail The mail to use.
Description$ The information string displayed for the attachment in the mail.
*Buffer The memory area of the data that should be added as the attachment. Once the attachment has been added, the memory area may be changed or freed, since its entire contents are copied into the mail.
BufferLength The size of the attachment in bytes.
MimeType$ (optional) The type of the attached file. If this parameter is omitted, then the file extension will be used to determine that files mime type. See the AddMailAttachment() command for a list of available mime types. If the extension of the file does not match any of the available mime types, then the "application/octet-stream" mime type will be used.

Return value

Returns nonzero if the attachment was added successfully and zero if not.

Remarks

Any number of attachments may be added to the mail, but the size limit available for a single attachment is currently set at 100MB. Most servers and clients do not have the capacity to handle attachments of that size, therefore it is advised that each attachment be kept to a reasonable size

Example

  InitNetwork()

  If CreateMail(0, "test@purebasic.com", "Hello")

    If AddMailAttachmentData(0, "Attachment 1", ?Hello, 5)
      Debug "Attachment correctly added"
    Else
      Debug "Attachment failed"
    EndIf
  EndIf


  DataSection
    Hello:
      Data.b 'H', 'e', 'l', 'l', 'o'

See Also

AddMailAttachment(), CreateMail()

Supported OS

All

<- AddMailAttachment() - Mail Index - AddMailRecipient() ->