|
-
Nov 26th, 2000, 06:21 PM
#1
Thread Starter
New Member
How can I save an Attchment from an e-mail that has been retreived using MAPISession & MAPIMessages objects from within VB. How can I Access the attachment. I just want to save it to a folder on my hard disk. Any help would be appreciated.
Regards
Eric Hart.
-
Nov 26th, 2000, 08:05 PM
#2
New Member
??? i dunno
Check the APItext viewer, maybee it has an api call...
"Beyond the pretty wrapping paper, all life is, is just a struggle between one hard spot and the next, puncuated by a failure of biological systems."- Codewarrior123
-
Nov 27th, 2000, 03:26 AM
#3
Member
Here is a way to access the mail in gerneral. If you want to access the attachment you will have to access objMail.attachments and maybe(I am not sure) the commant to save the attachment would be objMail.attachments.save
Good luck!
--------------------------------------------
Sub ReadFolder()
Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Dim intItemCount As Integer
'create objects, get mapi
Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
'get inbox
Set objFolder = objNS.GetDefaultFolder(olFolderInbox)
'loop thru inbox, display items
For intItemCount = 1 To objFolder.Items.Count
Set objMail = objFolder.Items.Item(intItemCount)
Debug.Print objMail.SenderName & ": " & objMail.Subject
Next intItemCount
'cleanup
Set objFolder = Nothing
Set objMail = Nothing
Set objNS = Nothing
Set objOL = Nothing
End Sub
-----------------------------------------------------
Life is trip, eat it and smile.
-
Nov 27th, 2000, 04:56 AM
#4
Addicted Member
Attachments collection
Each MAPI message has an Attachments collection. Each Attachment object has a WriteToFile method, so it becomes quite easy.
Code:
Dim AttachmentItem as MAPI.Attachment
For Each AttachmentItem In vMessage.Attachments
If AttachmentItem.Type = CdoFileData Then
strFilePath = TempPath & AttachmentItem.Name
Call AttachmentItem.WriteToFile(strFilePath)
End If
Next AttachmentItem
Hope this helps.
Shrog
-
Nov 29th, 2000, 03:55 AM
#5
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|