VBScriptSendMail ( toAddress ; messageSubject ; messageBody ; attachment_path1 ; attachment_path2 ; attachment_path3 ; openOutlook )
Rate this function: Average rating: 3.9 (72 votes)
Discuss this Custom Function
Rodrigo Torres, Challenge Day
For use on Windows - creates a VB Script that sends out an email with multiple (3) attachments.
|VBScriptSendMail ( firstname.lastname@example.org , Test Email , Hi Brian! Check out these attachments. , C:\test1.txt , C:\test2.txt ,
C:\test3.txt , 0 )
Dim MessageAttachment (3)
ToAddress = "email@example.com"
MessageSubject = "Test Email"
MessageBody ="Hi Brian! Check out these attachments."
MessageAttachment (1) = "C:\test1.txt"
MessageAttachment (2) = "C:\test2.txt"
MessageAttachment (3) = "C:\test3.txt"
Set oFileObj = CreateObject("Scripting.FileSystemObject")
Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem) newMail.Subject = MessageSubject newMail.Body = MessageBody &vbCrLf newMail.Recipients.Add(ToAddress)
N = 1
Do Until N > 3
If oFileObj.FileExists(MessageAttachment (N)) then newMail.Attachments.Add(MessageAttachment (N)) End If
N = N + 1
' Clean up
Set ToAddress = Nothing
Set MessageSubject = Nothing
Set MessageBody = Nothing
Set MessageAttachment (1) = Nothing
Set MessageAttachment (2) = Nothing
Set MessageAttachment (3) = Nothing
Set oFileObj = Nothing
Set ol = Nothing
Set olMailItem = Nothing
Set ns = Nothing
Set newMail = Nothing
Set myRecipient = Nothing
FileMaker's Send Mail script step is great until you need to send multiple attachments. FileMaker only allows one attachment. It is a limitation that has not been expanded yet.
This is a workaround for the PC Windows, using Outlook and VBScript (which will be run by Windows Script Host, at least it works for me on XP). See the comments at the top for details on the parameters and how to use it. I'm sharing this since it took me quite a while to put together and get it working, but it is provided "As is" and I make no guarantees.
6/8/09 - Updated to handle multiple paragraphs in the message body. - RT
6/10/09 - Updated to warn user if file does not exist. -RT
12/15/11 - Minor comment changes to clarify. -RT
Note: these functions are not guaranteed
or supported by BrianDunning.com. Please contact the individual
developer with any questions or problems.
This is my Custom Function and I want to
5 most recent comments | Show all 7 comments
Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:
Newest Custom Functions:
||ProperAllWords ( text )
||(Thu, Dec 14, 5:19pm)
||MatchExist ( SourceTable.Field ; DestTable.Field ; ReturnField )
||(Thu, Dec 14, 1:07pm)
||BVR_Format ( bvr )
||(Wed, Dec 13, 5:32pm)
||(Fri, Dec 08, 8:54am)
||(Thu, Dec 07, 4:27pm)
||JSONCreateVarsFromKeys ( json ; namespace )
||(Wed, Dec 06, 8:21pm)
||GetTableNzme ( field )
||(Tue, Dec 05, 9:16pm)
||TimeFormatAsText ( theTime )
||(Mon, Nov 13, 1:59pm)