View Single Post
  #1  
Old March 16th 07, 06:00 PM posted to microsoft.public.outlook.program_vba
Rob
external usenet poster
 
Posts: 146
Default Outlook Object Send Method

My boss is attempting to create an Outlook Application object to send emails
via a script written in the Integration Manager associated with Great Plains.
It is on a server running Outlook 2007. What follows is the code. Any
input as to why the Send method is not working? Thank you.

ERROR: Error Executing Script 'After Integration' Line 76:
Application-defined or object-defined error



Here's the code:

Dim olapp
Dim olnamespace
Dim olMailItem
Dim olnewmail


' Create outlook application object.
Set olapp = CreateObject("outlook.application")
MsgBox (" passed by create Object - Outlook app")

' get name space object
Set olnamespace = olapp.getnamespace("MAPI")
MsgBox (" passed by created getnamespace ")

Set olnewmail = olapp.CreateItem(olMailItem)
MsgBox (" passed by create olapp.createItem")


' Create the body of the email
strmessage = "Your GL batch " & BatchID & " was loaded successfully.
" & VbCrLf & VbCrLf _
& "Date Loaded: " & Date() & Space(5) & "Time Loaded: " & Time()
& VbCrLf & VbCrLf _

' Create the Subject
strsubject = (" " & CO & " Using Outlook: Trial Balance Has Been Imported
& Posted to Great Plains Successfully")
MsgBox ("passed by mail message content ")

' Set the message and subject
olnewmail.body = strmessage
olnewmail.subject = strsubject
MsgBox ("passed the body and subject lines")


' Testing against my email address

olnewmail.to = "

MsgBox ("passed mail item to: ")


'Send the e-mail

olnewmail.send '------ not working'

MsgBox ("passed by olnewmail.send line")

'Clean up

Set olapp = Nothing
Set olnamespace = Nothing
Set olnewmail = Nothing
Set olmailitem = Nothing

Ads