Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
General mail failure when sending e-mail from Excel Adrienne Excel Discussion (Misc queries) 5 November 4th 05 12:59 PM
Sending E-mail litew_8 Excel Worksheet Functions 1 November 21st 04 06:13 AM
Help sending mail... Bob Phillips[_6_] Excel Programming 1 August 12th 04 08:50 PM
Sending Mail from within Excel Don Lloyd Excel Programming 2 July 24th 04 09:28 PM
sending one sheet by e-mail gareth Excel Programming 3 November 7th 03 01:01 PM


All times are GMT +1. The time now is 02:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"