Platform: .NET
Class: Email
Method/Property: GetAttachedMessage
Question: I would like to download individual file attachments from an email that has already been forwarded. For example:
Dim bundle as Chilkat.EmailBundle
bundle = Mailman.CopyMail()
Dim email as Chilkat.Email
email = bundle.GetEmail(i)
Dim c as integer
For c = 0 to bundle.MessageCount - 1
If email.NumAttachedMessages > 0 then
'''how do I get the original email and download the file attachments if any.
else
Dim i as integer
For i = 0 to email.NumAttachments - 1
email.SaveAttachedFile(j, \"C:\FileAttachments\\")
next i
end if
next c
Answer:
You can get the embedded (attached) email as an Email object, and then fetch/save the attachments contained within it. For example:
...
If email.NumAttachedMessages > 0 then
Dim numAttached as integer
numAttached = email.NumAttachedMessages
Dim j as integer
for j = 0 to numAttached-1
Dim aEmail as Chilkat.Email
aEmail = email.GetAttachedMessage(j)
Dim i as integer
For i = 0 to aEmail.NumAttachments - 1
aEmail.SaveAttachedFile(i, \"C:\FileAttachments\\")
next i
next j
else
Dim i as integer
For i = 0 to email.NumAttachments - 1
email.SaveAttachedFile(i, \"C:\FileAttachments\\")
next i
end if
...