3 replies
by andrew
Here's a VB method that uses the CDONTS library (set a reference to CDONTS.DLL):
Dim oSession As CDONTS.Session
Dim oFolder As CDONTS.Folder
Dim oMessages As CDONTS.Messages
Dim oMessage As CDONTS.Message
Dim oAttachments As CDONTS.Attachments
Dim oAttachment As CDONTS.Attachment
Set oSession = New CDONTS.Session
oSession.LogonSMTP "Andrew", "awilliams@medcases.com"
Set oFolder = oSession.GetDefaultFolder(CdoDefaultFolderInbox)
Set oMessages = oFolder.MessagesFor Each oMessage In oMessages
If oMessage.Subject = "something" Then
Set oAttachments = oMessage.Attachments
For Each oAttachment In oAttachments
oAttachment.WriteToFile "filename.ext" Next
End If
Next
oSession.Logoff
This will loop through all the messages in your inbox, looking for one with a specific subject. When it finds it, it will loop through the attachments and save them. (you may want to make sure the names are unique if you expect more than one attachment)
Hope this helps.
by parli singh
by parli singh
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending