Const olByValue = 1 Const olMailItem = 0 Const olFolderSentMail =5 Const olFolderOutbox=4 Sub Main ' This SaxBasic script sends a document as an attachment to an email ' Raynald Levesque 2003/01/10 rlevesque@videotron.ca ' SPSS web site http://pages.infinit.net/rlevesqu/index.htm Dim appOutlook As Object 'The Outlook 2000 Application Dim mynamespace As Object Dim myfolder As Object Dim Newmail As Object 'The new email Dim strFileName As String 'The name and path of the file to send Dim strTo As String 'The email address of the recipient Dim myitem As Long 'Contains the number of emails in the SentFolder ' These infomation could be passed to the script by the syntax strFileName = "c:\\temp\\data with labels2.txt" strTo = "rlevesque@videotron.ca" strBody ="The file is attached." strSubject = "Email sent by SaxBasic" Set appOutlook=CreateObject("Outlook.Application") Set mynamespace=appOutlook.GetNamespace("MAPI") 'Set myfolder = mynamespace.PickFolder 'myfolder.Display Set Newmail = appOutlook.CreateItem(olMailItem) Newmail.Display Newmail.attachments.Add strFileName, olByValue , 1 Newmail.Body = strBody Newmail.To = strTo Newmail.Subject = strSubject Newmail.Send Set myfolder = mynamespace.GetDefaultFolder(olFolderOutbox) myitem = myfolder.Items.Count While myitem <> 0 'Message still being sent Wait 1 myitem = myfolder.Items.Count Debug.Print "wait...Still " & myitem & "messages in Outbox" Wend 'Close Outlook mynamespace.application.Quit Debug.Print strFileName & " has been sent..." End Sub