AddAttachment Method


Add an attachment.

long AddAttachment(
	[in] BSTR Name, 
	[in] BSTR ContentId, 
	[in] VARIANT Chunk
)

Parameters

Name

File name of attachment without path.

ContentId

If this attachment is an embedded picture, the value is the Content-ID of this attachment. Zero length string ("") indicates that current attachment doesn't have a Content-ID.

Chunk

Binary data of current attachment.

Return Value

Return value is zero if this method succeeds; otherwise return value is non-zero.

Usage Example

Dim server, user, password, requestAddr
server = "localhost"
user = "hunter@emailarchitect.net"
password = "mypassword"
requestAddr = "192.168.0.1"

Dim oSvr
Set oSvr = CreateObject("EmailArchitectObjects.ServerRoot")
r = oSvr.Connect( server, user, password, 0, requestAddr )
If r <> 0 Then
  WScript.Echo( "connect server failed!" )
  WScript.Quit
End If

Dim oDomains, oDomain
Set oDomains = oSvr.DomainCollection
Set oDomain = oDomains.Items(CStr(oSvr.Domain)) 

Dim oUsers, oUser
Set oUsers = oDomain.UserCollection
Set oUser = oUsers.Items(CStr(oSvr.User))

Dim oSmtp
Set oSmtp = oUser.NewSmtpMail
oSmtp.Charset = "iso-8859-1"
oSmtp.From = user
oSmtp.Subject = "test"
oSmtp.TextBody = "this is a test from emailarchitectobjects"
oSmtp.To = "dennis<dennis@emailarchitect.net>, test@emailarchitect.com"
oSmtp.CC = "cc@mydomain.com"

Dim oTool
Set oTools = CreateObject("EmailArchitectObjects.Tools")

oSmtp.AddAttachment "test.doc", "", oTools.ReadBinaryFile( "c:\test.doc" )

r = oSmtp.Send( 0, 0 )
If r <> 0 Then
  WScript.Echo( "send email failed!" )
  WScript.Quit
End If