AddMailAttachment()

Syntax

Result = AddMailAttachment(#Mail, Description$, Filename$ [, MimeType$])
Description
Add a file attachment to the mail.

Parameters

#Mail The mail to use.
Description$ The information string displayed for the attachment in the mail.
Filename$ The file to be added as an attachment. If the filename does not include a full path, it is interpreted relative to the current directory. Once the attachment is added, the local file may changed or deleted, as the entire content of the file is copied and attached to the mail.
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. Below there is a list of the 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

The available mime types are:
  application/acad          | AutoCAD    dwg
  application/clariscad     | ClarisCAD  ccad
  application/drafting      | MATRA Prelude drafting   drw
  application/dxf           | AutoCAD  dxf
  application/i-deas        | SDRC I-deas  unv
  application/iges          | Exchange format CAO IGES   igs,iges
  application/oda           | ODA  oda
  application/pdf           | Adobe Acrobat  pdf
  application/postscript    | PostScript   ai,eps,ps
  application/pro_eng       | ProEngineer  prt
  application/rtf           | Rich text   rtf
  application/set           | CAO SET  set
  application/sla           | stereolithography   stl
  application/solids        |  MATRA Solids   dwg
  application/step          | data STEP  step
  application/vda           | surface   vda
  application/x-mif         | Framemaker   mif
  application/x-csh         | Script C-Shell (UNIX)   dwg
  application/x-dvi         | text dvi  dvi
  application/hdf           | data hdf
  application/x-latex       | LaTEX  latex
  application/x-netcdf      | netCDF   nc,cdf
  application/x-sh          | Script Bourne Shell   dwg
  application/x-tcl         | Script Tcl  tcl
  application/x-tex         | file Tex  tex
  application/x-texinfo     | eMacs  texinfo,texi
  application/x-troff       | Troff  t,tr,troff
  application/x-troff-man   | Troff/macro man  man
  application/x-troff-me    | Troff/macro ME   me
  application/x-troff-ms    | Troff/macro MS   ms
  application/x-wais-source | Source Wais   src
  application/x-bcpio       | CPIO binary  bcpio
  application/x-cpio        | CPIO Posix  cpio
  application/x-gtar        | Tar GNU   gtar
  application/x-shar        | Archives Shell  shar
  application/x-sv4cpio     | CPIO SVR4n  sv4cpio
  application/x-sv4crc      | CPIO SVR4 avec CRC  sc4crc
  application/x-tar         | archive tar   tar
  application/x-ustar       | archive tar Posix   man
  application/zip           | archive ZIP   man
  audio/basic               | audio au,snd
  audio/x-aiff              | audio AIFF   aif,aiff,aifc
  audio/x-wav               | audio Wave   wav
  image/gif                 | Images gif  man
  image/ief                 | Images exchange format  ief
  image/jpeg                | Images Jpeg   jpg,jpeg,jpe
  image/png                 | Images Png  png
  image/tiff                | Images Tiff   tiff,tif
  image/x-cmu-raster        | Raster cmu  cmu
  image/x-portable-anymap   | Anymap PBM   pnm
  image/x-portable-bitmap   | Bitmap PBM   pbm
  image/x-portable-graymap  | Graymap PBM  pgm
  image/x-portable-pixmap   | Pixmap PBM   ppm
  image/x-rgb               | Image RGB   rgb
  image/x-xbitmap           | Images Bitmap X   xbm
  image/x-xpixmap           | Images Pixmap X   xpm
  image/x-xwindowdump       | Images dump X Window  man
  multipart/x-zip           | archive zip  zip
  multipart/x-gzip          | archive GNU zip  gz,gzip
  text/html                 | HTML   htm,html
  text/plain                | raw text txt,g,h,c,cc,hh,m,f90
  text/richtext             | rich text   rtx
  text/tab-separated-value  | value splitted text  tsv
  text/x-setext             | text Struct   etx
  video/mpeg                | Video MPEG   mpeg,mpg,mpe
  video/quicktime           | Video QuickTime  qt,mov
  video/msvideo             | Video Microsoft Windows  avi
  video/x-sgi-movie         | Video MoviePlayer  movie

Example

  InitNetwork()

  If CreateMail(0, "test@purebasic.com", "Hello")
    If AddMailAttachment(0, "Attachment 1", OpenFileRequester("Choose an attachment", "", "", 0))
      Debug "Attachment correctly added"
    Else
      Debug "Attachment failed"
    EndIf
  EndIf

See Also

AddMailAttachmentData(), CreateMail()

Supported OS

All

Mail Index - AddMailAttachmentData() ->