Forum Discussion

JNeedles's avatar
JNeedles
Contributor
11 years ago

Sending email via Outlook returning VBScript runtime error..

I'm modifying the sample Outlook code because I don't have variable parameters, and for some reason MI.Display works fine, but MI.Send generates a runtime error:







Sub SendReport'(Name1, Name2, Company, FileNameToAttach)

 

  Dim ObjItem, MI, i, CRLF

  Set MsOutlook = Sys.OleObject("Outlook.Application")

'  CRLF = Chr(13) + Chr(10)

 

 ' Set ObjItem = GetContactByName(Name1, Name2, Company)



'  If ObjItem Is Nothing Then

'    Call Log.Warning("User " + Name1 + " " + Name2 + _

'             " was not found in the address book.", _

'             "", pmHigher)

' Exit Sub

'  End If

    

  ' Creates a new message

  Set MI = MsOutlook.CreateItem(olMailItem)

 

  ' Sets the message subject

  MI.Subject = "Test Results"



  ' Sets the message text

  MI.Body = "Tert Results included"

     

  ' Specifies the destination address

  MI.To = "foo@foo.com"



  ' Attaches the script code

'  Call MI.Attachments.Add(FileNameToAttach, olByValue, Len(MI.Body), "Script")



'  MI.Display ' This line displays the new mail on screen.

             ' To send the mail, use the Send method 



   MI.Send

   

End Sub








this is the error:



 



Operation aborted

Error location:

Unit: "Trimark\Trimark\Script\SendResults"

Line: 56 Column: 4.

3 Replies