A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook Object Send Method



 
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old March 17th 07, 07:49 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook Object Send Method

Dumb question, was an email account set up?

It's also possible that the code is running into the security. Standalone
code can now use restricted methods like Send() if up-to-date A-V is running
on the machine but the A-V has to follow certain guidelines. Server side A-V
might not. Use On Error Resume Next and test for Err.Number to see better
what error you're getting.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Rob" wrote in message
...
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


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I can't send or recieve! error: object not found. Help! Maureen Outlook - Installation 0 January 7th 07 07:28 PM
Object automatically appears when I send an email Patty Stoddard Outlook - General Queries 3 May 7th 06 10:13 PM
an object is missing message appears when i press send/receive tafatr Outlook - General Queries 1 February 6th 06 12:37 PM
can't send/receive in OL2003. "operation failed. object missing" sk Outlook - Installation 0 January 26th 06 02:40 PM
Outlook: Send/Recieve error - An object could not be found? NRitchie Outlook - Installation 1 January 9th 06 04:40 AM


All times are GMT +1. The time now is 07:51 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.