Outlook item.save method

I am writing an app that creates messages and sends them to Microsoft Outlook using the following code:

Public Sub SaveOutlookMail(Subject As String, Recipient As _
String, Message As String)

Dim oLapp As Object
Dim oItem As Object

Set olApp = CreateObject("Outlook.application")
Set olItem = olApp .CreateItem(olMailItem)

With olItem
   .Subject = Subject
   .Recipients.Add (Recipient)
   .body = Message
   .Save
End With

Set olApp = Nothing
Set olItem = Nothing

Exit Sub

I would like the messages to be saved in the outbox to be sent later, but, for some reason, my messages are being saved to the inbox. Can anyone explain this please.
STKeithAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Unfortunately, the Save method saves the MailItem to the default folder.  

There is, however, a Move method that would let you move it to the Outbox from the Inbox.
0
STKeithAuthor Commented:
Thanks for the info. I have tried the Move method, but I can't get the message to Save and then Move within the same instance of the app. It only works if I save first, close the app, open a new instance of the app, find the message, and then move it.
0
Bob LearnedCommented:
I tried this to test the theory out:

Dim appOutlook As New Outlook.Application
Dim itmMail As Outlook.MailItem
Dim foldDestination As Outlook.MAPIFolder


   Set itmMail = appOutlook.CreateItem(olMailItem)
   
   Set foldSource = appOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderDrafts)
   Set foldDestination = appOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox)
   
   With itmMail
      .To = "Robert Learned"
      .Subject = "Test"
      .Body = "This is a test"
      .Save
      .Move foldDestination
   End With


The new mail item was saved into the Draft folder, and moved into the Outbox.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

STKeithAuthor Commented:
This code does not work for me, I get the following error when it reaches the Move method:

Run-time error '-2147417851':
Method 'Move' of object '_DMailItem' failed.
0
Bob LearnedCommented:
A good place to start would be to ask what version of Outlook are you using?  I am using Outlook 98?

The next question would be what platform?  I am using Windows NT 4.0 SP5.
0
STKeithAuthor Commented:
I am using Outlook 97 and Windows 95.
0
Bob LearnedCommented:
Have you ever thought about upgrading to Outlook 98?  It's a free upgrade from Micro$oft!
0
STKeithAuthor Commented:
I'll look into it. Thanks.
0
Bob LearnedCommented:
Was this any help to you?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
STKeithAuthor Commented:
Yes, this was helpful. I still have to do a couple of "work-arounds" between saving and moving, but I think I can get the job done now. Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.