Adding attachments to a HTML mail isn't too difficult, but I only got it to work by extracting the files that need to be attached to a temporary directory on the filesystem first. As I recall it isn't possible in LotusScript to create a NotesStream object from a document attachment directly.
The code I use looks something like this (lstFileAttachments is a string list containing the full path to a number of files):
dim strContentType$
Forall file In lstFileAttachments
Select Case Lcase(Strright(file, ".") )
Case "gif"
strContentType = "image/gif"
Case "jpeg", "jpg"
strContentType = "image/jpeg"
Case Else
strContentType = "application/octet-stream"
End Select
Set Me.mc = Me.body.createChildEntity()
Set Me.mh = Me.mc.CreateHeader("Content-Disposition")
Hi Jake,
Adding attachments to a HTML mail isn't too difficult, but I only got it to work by extracting the files that need to be attached to a temporary directory on the filesystem first. As I recall it isn't possible in LotusScript to create a NotesStream object from a document attachment directly.
The code I use looks something like this (lstFileAttachments is a string list containing the full path to a number of files):
dim strContentType$
Forall file In lstFileAttachments
Select Case Lcase(Strright(file, ".") )
Case "gif"
strContentType = "image/gif"
Case "jpeg", "jpg"
strContentType = "image/jpeg"
Case Else
strContentType = "application/octet-stream"
End Select
Set Me.mc = Me.body.createChildEntity()
Set Me.mh = Me.mc.CreateHeader("Content-Disposition")
Call Me.mh.SetHeaderVal({attachment; filename="} & Listtag(file) & {"} )
'only required if we're embedding something we need to reference later on
'Set Me.mh = Me.mc.CreateHeader("Content-ID")
'Call Me.mh.SetHeaderVal( |<| & Listtag(file) & |>| )
Set streamFile = ttSession.s.CreateStream
If streamFile.Open(file) Then
Call Me.mc.SetContentFromBytes(streamFile, strContentType & {; name="} & Listtag(file) & {"}, ENC_IDENTITY_BINARY)
Call streamFile.Close
End If
End Forall