I've been using the NotesMIMEEntity class for a while now and have worked with
attachments too. The files you want to send have to be (temporarily) on the
server's file system to be able to read them into a MIMEEntity (I didn't find a
way to read embedded objects to a stream directly).
The following code should help you on the right track:
'create mime attachments for every file
Forall file In strFileAttachments
'set correct content types for known file types
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 mimeChild = mimeRoot.CreateChildEntity
Set header = mimeChild.CreateHeader("Content-Disposition")
Call header.SetHeaderVal({attachment; filename="} & Listtag(file) & {"}
)
'only required if we're embedding something we need to reference later
on, i.e. inline images
'Set header = mimeChild.CreateHeader("Content-ID")
'Call header.SetHeaderVal( |<| & Listtag(file) & |>| )
Set stream = session.CreateStream
If stream.Open(file) Then
Call mimeChild.SetContentFromBytes(stream, strContentType & {; name="}
& Listtag(file) & {"}, ENC_IDENTITY_BINARY)
Call stream.Close
End If
End Forall
Hi Salvador,
I've been using the NotesMIMEEntity class for a while now and have worked with attachments too. The files you want to send have to be (temporarily) on the server's file system to be able to read them into a MIMEEntity (I didn't find a way to read embedded objects to a stream directly).
The following code should help you on the right track:
dim strFileAttachments List As String
strFileAttachments("image.gif") = "c:\somewhere_on_your_server\image.gif" strFileAttachments("word.doc") = "c:\somewhere_on_your_server\word.doc"
'create mime attachments for every file Forall file In strFileAttachments 'set correct content types for known file types 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 mimeChild = mimeRoot.CreateChildEntity Set header = mimeChild.CreateHeader("Content-Disposition") Call header.SetHeaderVal({attachment; filename="} & Listtag(file) & {"} ) 'only required if we're embedding something we need to reference later on, i.e. inline images 'Set header = mimeChild.CreateHeader("Content-ID") 'Call header.SetHeaderVal( |<| & Listtag(file) & |>| ) Set stream = session.CreateStream If stream.Open(file) Then Call mimeChild.SetContentFromBytes(stream, strContentType & {; name="} & Listtag(file) & {"}, ENC_IDENTITY_BINARY) Call stream.Close End If End Forall