View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_3_] Dick Kusleika[_3_] is offline
external usenet poster
 
Posts: 599
Default Help sending mail...


The problem is if Outlook is open I don't get the
little warning from Outlook and instead of sending the email it places it

in
the drafts folder. If Outlook is closed everything works fine.

With CreateObject("Outlook.Application")
With .CreateItem(0) 'olMailItem
.To = Recpt ' The recipient's email address
.Subject = Sbjct
.Body = Bdy
.Attachments.Add Fname
.Save
If ObjPtr(.Parent.Session.Application.ActiveExplorer) = 0 Then
.Send
End If


The Save method puts it in the Drafts folder, so get rid of that line. The
Send method will put it in the Outbox. When Outlook is running and visible,
ActiveExplorer will return a non-zero ObjPtr, but if it's invisible, there
will be no ActiveExplorer and ObjPtr will return zero. If ObjPtr returns
zero, it will not send and will just save the email to the Drafts folder. I
think you can just get rid of the whole IF block and just Send. If the user
is connected to the internet, it will Send it immediately. If not, it will
store it in the Outbox until a valid Send/Receive is executed from Outlook.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com