Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Dan Baker
  Where is Dan Baker?
 Effort of the Poconos
 Pennsylvania - United States
 Dan Baker
 Tags
Subject: Must Outlook be open to send VFP emails
Thread ID: 394099 Message ID: 394099 # Views: 49 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Monday, December 30, 2013 4:54:52 PM         
   


Foxites:

I am using the Pete Sass contributed method to send email through Outlook.   Code is below.

I have no trouble sending the email as long as Outlook is open on my computer. But when I remove the .Display instruction below, no email is sent.   Is there a way to send messages through Outlook without opening that application for view?

Thanks,

Dan B.

*
* Send email via outlook
*

lcMailTo       = TRIM(emaillog.to_address)
lcEmailSubject = TRIM(emaillog.subject)+thisform.SubjectSuffix
* lEmailAtt ="Qualified path and file name to attach"


* --- Error trap in the event of an OutLook initialization failure. 
llEmailErr = .F.
ON ERROR llEmailErr = .T.
#DEFINE MAILITEM 0

* --- Create OutLook application object.
oOutLookObject = CreateObject('Outlook.Application')
ON ERROR
IF llEmailErr = .T.
   = MessageBox("OutLook initialization error has occurred!",0-16,"OutLook Error")
   llEmailErr = .F.
   RETURN
ENDIF
* --- Create the outLook object item.
oEmailItem = oOutLookObject.CreateItem(MAILITEM)

* --- Setup the email to be sent.
WITH oEmailItem
   .To		= lcMailTo
*   .CC      = 
   .Subject = lcEmailSubject
   .Body = "Completed log file: "+thisform.LogFileURL
*   .Attachments.Add(lEmailAtt) && Note that the fully qualified path and file is required.
   .Display
ENDWITH

* --- Clean up and release things.
RELEASE oEmailItem
RELEASE oOutLookObject



ENTIRE THREAD

Must Outlook be open to send VFP emails Posted by Dan Baker @ 12/30/2013 4:54:52 PM
RE: Must Outlook be open to send VFP emails Posted by David Mustakim @ 12/30/2013 5:14:08 PM
RE: Must Outlook be open to send VFP emails Posted by Stefan Wuebbe @ 12/30/2013 5:20:27 PM
RE: Must Outlook be open to send VFP emails Posted by Dan Baker @ 12/30/2013 9:22:37 PM
RE: Must Outlook be open to send VFP emails Posted by Pete Sass @ 12/30/2013 6:42:30 PM
RE: Must Outlook be open to send VFP emails Posted by Stefan Wuebbe @ 12/30/2013 7:09:12 PM
RE: Must Outlook be open to send VFP emails Posted by Pete Sass @ 12/30/2013 7:39:09 PM
RE: Must Outlook be open to send VFP emails Posted by Stefan Wuebbe @ 12/30/2013 7:51:01 PM
RE: Must Outlook be open to send VFP emails Posted by David Mustakim @ 12/30/2013 8:07:59 PM
RE: Must Outlook be open to send VFP emails Posted by Pete Sass @ 12/30/2013 8:24:13 PM
RE: Must Outlook be open to send VFP emails Posted by David Mustakim @ 12/30/2013 8:36:41 PM
RE: Must Outlook be open to send VFP emails Posted by Pete Sass @ 12/30/2013 11:21:11 PM
RE: Must Outlook be open to send VFP emails Posted by Russell Hill @ 12/30/2013 7:43:17 PM
RE: Must Outlook be open to send VFP emails Posted by Dan Baker @ 12/30/2013 11:32:27 PM
RE: Must Outlook be open to send VFP emails Posted by Dan Baker @ 12/30/2013 11:49:24 PM