WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Outlook Object Send Method

 
   Home -> Office -> Programming VBA RSS
Next:  need help editing subject lines in recieved email..  
Author Message
Rob

External


Since: Nov 16, 2004
Posts: 359



(Msg. 1) Posted: Fri Mar 16, 2007 10:00 am
Post subject: Outlook Object Send Method
Archived from groups: microsoft>public>outlook>program_vba (more info?)

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 = "person@work.com"

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
Back to top
Login to vote
Ken Slovak - [MVP - Outlo

External


Since: Oct 17, 2003
Posts: 2999



(Msg. 2) Posted: Sat Mar 17, 2007 2:49 pm
Post subject: Re: Outlook Object Send Method [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <Rob.RemoveThis@discussions.microsoft.com> wrote in message
news:ACF25B43-AC3F-4D6B-BBE4-C3F6D14300A7@microsoft.com...
> 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 = "person@work.com"
>
> 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
>
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support