ilogic - attach folder contents

ilogic - attach folder contents

Anonymous
Not applicable
736 Views
3 Replies
Message 1 of 4

ilogic - attach folder contents

Anonymous
Not applicable

Hi everyone 🙂

 

 

Does anyone have some code that they could kindly share - OR - point me in the right direction to attaching the contents of a given folder to an email.

 

I dont want to attach a compressed file (zip) just to attach the entire contents of a folder.. it could be for pdf files only or for any file extension.

 

I've spent a few hours on this and got no where fast... attaching a single file is something within my ability but sadly I'm lost with regards attaching multiple files

 

many thanks to all who reply...

 

b

 

 

 

0 Likes
Accepted solutions (1)
737 Views
3 Replies
Replies (3)
Message 2 of 4

Owner2229
Advisor
Advisor
Accepted solution

Hi, see the code below. You should modify the blue hightlighted parts.

 

'send email using outlook
Dim oOApp
Dim oOMail
oOApp = CreateObject("Outlook.Application")
oOMail = oOApp.CreateItem(olMailItem)
Dim olNs
olNs = oOApp.GetNamespace("MAPI")
olNs.Logon

'you can use this to select path manualy Dim dialog = New System.Windows.Forms.FolderBrowserDialog() dialog.SelectedPath = ThisDoc.Path dialog.ShowNewFolderButton = True If System.Windows.Forms.DialogResult.OK = dialog.ShowDialog() Then oPath = dialog.SelectedPath Else Exit Sub End If
'or use this to select path of currently opened file (you have to uncomment it) 'oPath = ThisDoc.Path
With oOMail .To = "someone@something.com" .Subject = "Some Subject Line Here" .Body = "Some Text Here" 'Add attachments to the message For Each oFile In System.IO.Directory.GetFiles(oPath, "*.pdf") objOutlookAttach = .Attachments.Add(oFile) Next
'send the email instantly, otherwise just saves it to folder "for send" .Send End With

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 3 of 4

Anonymous
Not applicable

I am owe you several virtual beers Mike! 🙂

 

interstingly enough, a bit of that code is exactly what I needed for another rule too but was uinsure how to implement..

 

I need to sit down and get my head around msdn / vb...

 

many thanks again!! most appreciated!!

 

 

0 Likes
Message 4 of 4

Owner2229
Advisor
Advisor

You're welcomed 🙂

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes