Software Venture Consulting
ToMarket

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Brian Dunning
Contact me | vCard


Brian on CNN
Brian on CNN


Brian on CBS Radio


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

VBScriptSendMail ( toAddress ; messageSubject ; messageBody ; attachment_path1 ; attachment_path2 ; attachment_path3 ; openOutlook )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 3.1  (10 votes)
  Discuss this Custom Function

Rodrigo Torres, Challenge Day
http://www.challengeday.org

For use on Windows - creates a VB Script that sends out an email with multiple (3) attachments.

Sample Input:
VBScriptSendMail ( brian@email.address , Test Email , Hi Brian! Check out these attachments. , C:\test1.txt , C:\test2.txt ,
C:\test3.txt , 0 )
Sample Output:
Option Explicit
Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim MessageAttachment (3)
Dim oFileObj
Dim ol
Dim olMailItem
Dim ns
Dim newMail
Dim myRecipient
Dim N
ToAddress = "brian@email.address"
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
Loop
newmail.send
' 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


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

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.

Have fun!
===============
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

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 edit it

Discuss:

There are no comments yet. Be the first to post a comment about this Custom Function! Please try to keep it brief & to the point. Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 5 + 8 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. GetResultParameter( ParameterName )
  (Wed, Aug 25, 8:32am)
2. GetListParameter ( ParameterList ; ParameterName )
  (Wed, Aug 25, 8:25am)
3. Standard_Deviation( Field ; MaxLoopCount ; StartIndex ; StdDeviation ; ArithMeanValue )
  (Tue, Aug 24, 10:57am)
4. Arithmetic_Mean ( Field ; MaxLoopCount ; StartIndex ; MeanValue )
  (Tue, Aug 24, 10:51am)
5. Age ( Birth; theDate; Format )
  (Fri, Aug 20, 9:50am)
6. Power ( x ; y )
  (Thu, Aug 19, 5:56am)
7. portal.rowCount ( _name )
  (Sun, Aug 15, 2:41pm)
8. PostPer_Day ( Post; startDate ; finishDate ; returnType )
  (Sat, Aug 14, 2:02pm)

RSS Feed of Custom Functions