Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help sending mail...
Thank you guys very much for your help! Maybe someday I will have learned
enough about VBA to actually answer someone elses question! Thanks again. "Dick Kusleika" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
General mail failure when sending e-mail from Excel | Excel Discussion (Misc queries) | |||
Sending E-mail | Excel Worksheet Functions | |||
Help sending mail... | Excel Programming | |||
Sending Mail from within Excel | Excel Programming | |||
sending one sheet by e-mail | Excel Programming |