• Subject: Re: Attach Files to a message - loop through subdirectory
  • Author: Harvey Richardson
  • Date: 26 May 2011
  • References: 1
Not sure this is the cleanest code, but I got it to work! Here it is if anyone needs it: Sub MyIMAPMacro() Dim myFileName As String thefilepath = "s:\scan\To IMAP\" theemail = "email@me.com.au" myFileName = Dir("" & thefilepath & "*.*") Do While myFileName <> "" Set myOutlook = CreateObject("Outlook.Application") Set mymail = myOutlook.CreateItem(olMailItem) myFileName = Dir("" & thefilepath & "*.*") mymail.Attachments.Add thefilepath & myFileName mymail.Recipients.Add theemail lenmyfilename = Len(myFileName) If Right(myFileName, 4) = ".pdf" Then thesubject = Left(myFileName, lenmyfilename - 4) Else thesubject = myFileName End If mymail.Subject = thesubject mymail.Body = thesubject mymail.Send Kill thefilepath & myFileName myFileName = Dir Set myOutlook = Nothing Set mymail = Nothing Loop MsgBox "Completed" End Sub
26 May 2011Attach Files to a message - loop through subdirectory.Harvey Richardson
26 May 2011\ Re: Attach Files to a message - loop through subdirectory.Harvey Richardson
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)