Multiple email attachments

11 posts / 0 new
Last post
fostc
Offline
Joined: 09/18/2018 - 03:39
Multiple email attachments

Hi
I was wondering if there was any way of attaching multiple files using Client.SendEMail?  I would like to email the output files from my script and I would like to just send one email with multiple attachments rather than multiple emails with one attachment.
Thanks
Chris

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Chris,

It appears you can only send one but you can access email directly through the script.  Check out this post and see if it helps you out. http://ideascripting.com/content/example-sending-email-using-outlook-usi...

Brian

fostc
Offline
Joined: 09/18/2018 - 03:39

Hi Brian
When I click on the link I get an "Access Denied" message.
Regards
Chris

fostc
Offline
Joined: 09/18/2018 - 03:39

Hi Brian
Is there any reason why I can't access the post via the link?  I am still getting an access denied message even though I am logged in.
 
Many thanks
Chris

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Chris, thanks for the reminder.  We had some severe weather here last Friday that caused lots of problems and I had forgotten about this post.  I copied it over.

 

This is an example script of how to use IDEAScript to interface with outlook.  Here is the script and the sample data file.

Sub Main
	Dim OutApp As Object
	Dim OutMail As Object
	Dim db As database
	Dim rs As Object
	Dim rec As Object
	Dim sSubject As String
	Dim sMessage As String
	Dim i As Long
	Dim count As Long
	Dim CrLf As String
	
	CrLf = Chr(10) & Chr(13)
	
	Set db = Client.OpenDatabase("outlook-Sheet1.IMD") 
		
		Set rs = db.RecordSet
			count = rs.Count
			rs.ToFirst
			For i = 1 To count
				rs.next
				Set OutApp = CreateObject("Outlook.Application")
					Set OutMail = OutApp.CreateItem(0)

						Set rec = rs.ActiveRecord
						sSubject = "This email is for " & rs.ActiveRecord.GetCharValue("FIRST_NAME") & " " &  rs.ActiveRecord.GetCharValue("LAST_NAME") 
						sMessage = "Dear " & rs.ActiveRecord.GetCharValue("FIRST_NAME")  & CrLf & CrLf 
						sMessage = sMessage & "This is the body of the email, this is the amount " & rs.ActiveRecord.GetNumValue("AMOUNT") 
						sMessage = sMessage & " and this is the text " & rs.ActiveRecord.GetCharValue("TEXT") 
						On Error Resume Next
						' Change the mail address and subject in the macro before you run it.
						'MsgBox rs.ActiveRecord.GetCharValue("EMAIL_ADDRESS") 
						OutMail.To = rs.ActiveRecord.GetCharValue("EMAIL_ADDRESS") 
						OutMail.CC = ""
						OutMail.BCC = ""
						OutMail.Subject = sSubject
						OutMail.Body = sMessage
						' You can add other files by uncommenting the following line.
						'.Attachments.Add ("C:\test.txt")
						' In place of the following statement, you can use ".Display" to
						' display the mail.
						OutMail.Display
						OutMail.Send   
						On Error GoTo 0
					Set OutMail = Nothing
				Set OutApp = Nothing

			Next i
		Set rec = Nothing
		Set rs = Nothing
	Set db = Nothing
		
End Sub

 

marconb10
Offline
Joined: 11/13/2019 - 12:39

Hi Brian! I hope you and your family are doing well! If you don't mind, would you help me with a little thing today? the line "OutMail.send" is not working. It's not sending the e-mail. (I can even comment this line).I have 15 different e-mails that I have to send, and using this code, it creates these 15 e-mails, but I still have to click in each "Send" button inside Outlook...  doing it 15 times it's not good haha, so I would like to check with you if something changed in this "OutMail" that it's not sending automatically.
Thank you!!

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

We had this problem on a test back in January.  What fixed it was actually just updating to the latest version of outlook and then it worked.  You mind making sure you have the latest update installed and try again.

marconb10
Offline
Joined: 11/13/2019 - 12:39

Brian! I fixed it (I mean, my problem haha).
I just used this : SendKeys "^~"
Inside outlook, i did check the box where says about sending e-mails when Ctrl+Enter are pressed together.
Thank you!

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

That is interesting, glad you got it working and thanks for sharing your solution.

Johschan1
Offline
Joined: 12/09/2020 - 20:48

Hello i just tried but i am gettin errors.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Johschan1, which version of IDEA do you have.  In the latest there is added functionality for sending emails.