I have an Excel spreadsheet that generates a Lotus Notes email with an excel spreadsheet attached. That spreadsheet gets sent out to a bunch of people, who generate Lotus Notes back to me with the excel attachments. My Access database would like to read through those emails in my Inbox and strip off the attached excel files into a directory on my C:\ drive. I have code that should work, but it's not recognizing the message type of the Lotus Notes as RICHTEXTFORMAT. See code and note below.
CODE TO DETACH EXCEL ATTACHMENT FROM LOTUS EMAIL
Sub Get_EMAIL_Attachment()
Dim View As Object
Dim nDoc As Object
Dim itm As Variant
Dim ITM1 As Variant
Dim attachment As NotesEmbeddedObject
Const RICHTEXT = 1
Const EMBED_ATTACHMENT = 1454
Const sPathToSave = "C:\EMAIL_EXTRACTS\"
Set s = CreateObject("Notes.Notessession") 'create notes session
Set db = s.GetDatabase("", "") 'Orwell", "Mail\CS\Repoteam.nsf") 'set db to database not yet named
Call db.openmail
Set View = db.GetView("($Inbox)")
Set nDoc = View.GetFirstDocument
While Not (nDoc Is Nothing)
If nDoc.HasEmbedded Then
Set itm = nDoc.GetFirstItem("Body")
' The following line is where I'm having a problem. The itm.Type for RICHTEXT IS "1", but
' my itm.Type for my attachment is "1280" and it skips over the detach logic...help!
If itm.Type = RICHTEXT Then
Dim attch As Variant
For Each attch In itm.EmbeddedObjects
If (attch.Type = EMBED_ATTACHMENT) Then
attch.ExtractFile sPathToSave & attch.Name
End If
Next
End If
End If
Set nDoc = View.GetNextDocument(nDoc)
Wend
MsgBox "Email search completed."
End Sub
CODE TO DETACH EXCEL ATTACHMENT FROM LOTUS EMAIL
Sub Get_EMAIL_Attachment()
Dim View As Object
Dim nDoc As Object
Dim itm As Variant
Dim ITM1 As Variant
Dim attachment As NotesEmbeddedObject
Const RICHTEXT = 1
Const EMBED_ATTACHMENT = 1454
Const sPathToSave = "C:\EMAIL_EXTRACTS\"
Set s = CreateObject("Notes.Notessession") 'create notes session
Set db = s.GetDatabase("", "") 'Orwell", "Mail\CS\Repoteam.nsf") 'set db to database not yet named
Call db.openmail
Set View = db.GetView("($Inbox)")
Set nDoc = View.GetFirstDocument
While Not (nDoc Is Nothing)
If nDoc.HasEmbedded Then
Set itm = nDoc.GetFirstItem("Body")
' The following line is where I'm having a problem. The itm.Type for RICHTEXT IS "1", but
' my itm.Type for my attachment is "1280" and it skips over the detach logic...help!
If itm.Type = RICHTEXT Then
Dim attch As Variant
For Each attch In itm.EmbeddedObjects
If (attch.Type = EMBED_ATTACHMENT) Then
attch.ExtractFile sPathToSave & attch.Name
End If
Next
End If
End If
Set nDoc = View.GetNextDocument(nDoc)
Wend
MsgBox "Email search completed."
End Sub