View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Lloyd Don Lloyd is offline
external usenet poster
 
Posts: 119
Default Deferred Mailing from Outlook

Hi,

After doing enough research to warrant an automatic award of a Ph.D or two,
I have come up with the following gem.
Unfortunately, it doesn't work as it should!

The objective is to prepare an e-mail with an attachment and to place it in
the Drafts Folder for notes to be added prior to sending.

Sub DeferredMail()
Dim Fname, Sbjct

ActiveSheet.Copy
Fname = "C:\MailTemp\" & "TempMail.xls"
ActiveWorkbook.SaveAs Fname
ActiveWorkbook.Close False
Sbjct = "Just Testing"

Dim olApp As Object
Dim olMail As Object
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(olMailItem)

With olApp
..Session.GetDefaultFolder (16) '(olFolderDrafts)
With olMail
.To = "
.Subject = Sbjct
.Body = "Notes:"
.Attachments.Add Fname
.Save
End With
End With

Set olApp = Nothing
Set olMail =
End Sub

The problem is as follows:
If the routine is run when Outlook is open, it works as intended and the
e-mail goes to the Drafts Folder.
However, if Oulook in NOT open when the routine is run, when it is
subsequently opened, the e-mail appears in the Inbox, which is not
acceptable.

Any ideas ?

TIA
regards'

Don