AddAttachmentEx Method

Attach a file or URL to current email with customized file name.

[Syntax]
C++: HRESULT AddAttachmentEx( BSTR strFile, BSTR strAlt, long* pVal )
Visual Basic: AddAttachmentEx( strFile As String, strAlt As String ) As Long
C#: long AddAttachmentEx( string strFile, string strAlt )

Parameter:

strFile

File or URL to be attached.

strAlt

File name to be displayed in current email.

Return Values

If this method succeeds, the return value is zero; otherwise the return value is non-zero.


Remarks

strFile must be a valid local file with full path or a valid URL.

Usage Example:

[Visual Basic]
Private Sub SendEmail()
  Dim oSmtp As AOSMTPLib.Mail
  Set oSmtp = New AOSMTPLib.Mail

  oSmtp.ServerAddr = "mail.adminsystem.net"
  oSmtp.FromAddr = "test@adminsystem.net"
  oSmtp.AddRecipient "Support Team", "support@adminsystem.net", 0
  oSmtp.BodyText = "Hello, this is a test...."
  
  If oSmtp.AddAttachmentEx( "c:\test.doc", "mytest.doc" ) <> 0 Then
    MsgBox "add attachment failed"
    Exit Sub
  End If
 
  If oSmtp.SendMail() = 0 Then
    MsgBox "Message delivered!"
  Else
    MsgBox oSmtp.GetLastErrDescription()
  End If
End Sub

See Also

ClearAttachment Method


2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.