Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OutLook97 Sending message From VBScript: Why failed ?

Status
Not open for further replies.

larryjr

Technical User
Aug 27, 2001
20
0
0
JP
******************************************************
Dim ol,ns,newMessage,nl,myUser
Set ol = CreateObject("Outlook.Application")
Set ns = ol.GetNamespace("MAPI")
On Error Resume Next
ns.Logon "Microsoft Outlook Internet Settings"
if Err then
Err.Clear
Set ol = Nothing
Set ns = Nothing
Set ol = CreateObject("Outlook.Application")
Set ns = ol.GetNamespace("MAPI")
myUser = ns.CurrentUser.Name
End if
On Error GoTo 0
nl = Chr(10)
myBody = "Multi-Layer Ship Log for " & rundate
Set newMessage = ol.CreateItem(olMailItem)
With newMessage
.Subject ="TEST Transmittal" & rundate & " Exception report also"
.Body = myBody
.Recipients.Add("XXXX@XXXX.com").Type = olTo
.Send
End With
ns.Logoff
Set ol = Nothing
*********************************************************
This VBScript failed using with WSH requesting a transport
provider by outlook97 though suceeded with VBA in Excel97.
I need a solution for this.

 
Could anyone help me for this ?
 
I replaced:
With newMessage
.Subject ="TEST Transmittal" & rundate & " Exception report also"
.Body = myBody
.Recipients.Add("XXXX@XXXX.com").Type = olTo
.Send
End With

with:

With newMessage
.Subject ="TEST Transmittal" & rundate & " Exception report also"
.Body = myBody
.To = "xxx@xxx.com"
.Send
End With

and it seemed to work. Not sure if it's what you're after.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top