Attach a folder to email

Attach a folder to email

Anonymous
Not applicable
509 Views
3 Replies
Message 1 of 4

Attach a folder to email

Anonymous
Not applicable

Is there a VBA/iLogic code to attacht a folder (all files in that folder) in a e mail?

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

rossano_praderi
Collaborator
Collaborator
Accepted solution

This sample works only with the microsoft frameworks 4.5 and above.

 

AddReference "F:\Progetti\Inventor\Progetti_2015\Compressione\dll\InvMyZip.dll" ' change the path with the correct dll location

Sub Main
	cFolder = "f:\TestZip" ' the folder to compress
	oZip = "f:\TestZip.zip" ' compressed file location and name
Dim CompressFolder As New InvMyZip.InvMyZip 
	CompressFolder.oZip(cFolder, oZip)
	If System.IO.File.Exists(oZip) Then
		SendMail("spam@dshortway.com", "SendMail Ilogic Rule Test Message", oZip, _
				"Test message from Ilogic rule SendMail" & vbCr _
					& "With multiline text in the body message!")
	End If
CompressFolder = Nothing
End Sub

Private Sub SendMail(ToAdress as String, tSubject As String, aFile As String, tBody As String)
Dim OlApp As Object = CreateObject("Outlook.Application")
Dim eMail As Object = OlApp.CreateItem(0)
	With eMail
		.To = ToAdress
		.Subject = tSubject
		.attachments.Add(aFile)
		.Body = tBody
		.Display
		'.Mail.Send ' uncomment this line if you want send your message immediately
	End With
OlApp = Nothing
eMail = Nothing
End Sub

 

This sample and the attached files have to be considered "as is".

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 3 of 4

Anonymous
Not applicable

Than you Rossano!!!

it works

0 Likes
Message 4 of 4

rossano_praderi
Collaborator
Collaborator
Accepted solution
Mark as solution, please.


--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes