Programatically detaching outlook attachments

  • Thread starter Thread starter Easy Joe
  • Start date Start date
E

Easy Joe

I was wondering if it is possible to use VBA (Excel) to
automatically detach an Outlook 98 attachment and import
the data into Excel. I see a lot of postings on how to
send e-mail through VBA automatically, but nothing to
detach and import files from Outlook automatically.

Any suggestions?

Thanks,
Joe
 
Easy Joe said:
I was wondering if it is possible to use VBA (Excel) to
automatically detach an Outlook 98 attachment and import
the data into Excel. I see a lot of postings on how to
send e-mail through VBA automatically, but nothing to
detach and import files from Outlook automatically.

Any suggestions?

Thanks,
Joe

Code snippet:

lAttachIndex = 1
Do While objMail.Attachments.Count > 0 And lAttachIndex <=
objMail.Attachments.Count
Set objAttach = objMail.Attachments(lAttachIndex)
DoEvents
If objAttach.Type = olByValue Or objAttach.Type =
olEmbeddeditem Then
strFileName = objAttach.FileName
If strFileName = "" Then
strFileName = Replace(objAttach.DisplayName, "
", "")
strFileName = Left(strFileName, InStr(1,
strFileName, ".") + 3)
strFileName = Replace(strFileName, ":", "")

End If

strFileName = "c:\attachments\" & strFileName

objAttach.SaveAsFile strFileName
objAttach.Delete
objMail.save


etc...

--
John Blessing

http://www.LbeHelpdesk.com - Help Desk software at affordable prices
http://www.free-helpdesk.com - Completely free help desk software !
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook
 
Back
Top