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
 To: Dan Baker
  Where is Dan Baker?
 Effort of the Poconos
 Pennsylvania - United States
 Dan Baker
 Tags
Subject: RE: Must Outlook be open to send VFP emails
Thread ID: 394099 Message ID: 394146 # Views: 31 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Monday, December 30, 2013 11:49:24 PM         
   


Thanks to everyone providing help.

I found a workable solution as follows.

A nice method provided by Jijo Pappachan allows you
to check whether Outlook is currently open or not.

If it's already open, I will not close Outlook after the email is inserted because there
are bound to be messages not quite complete and not saved.

But if Outlook is not open, then I can open it for a second or two, insert the email, then close it.

The following method puts the message in my Draft folder. It does not allow me to Send it directly, but that's
fine for my purposes because I can send it later.

I adapted the method from Microsoft Office Automation with Visual FoxPro (Hentzwerke) for my main
email routine:

*
* Send_Emai_via_Outlook 
* 

LOCAL oOutlook, oNameSpace, oExplorer, oMailItem as Object
LOCAL lOutlookOpenAlready as Logical 

SELECT vfpsafe && mdot protection ( file has 1 date field with a gibberish name )

* Get log information to populate the email message
thisform.email_get_log_data() 

* See if Outlook is already open, so we can decide whether or not to close Outlook
* after we send the message. 
lc_WasOutLookOpen = thisform.Outlook_is_it_open()  

#DEFINE olMailItem 0
#DEFINE olFolderDisplayNormal 0
#DEFINE CR CHR(13)

* Start Outlook -- or join the application already open 
oOutlook = CreateObject("Outlook.Application")

oNameSpace = oOutlook.GetNameSpace("MAPI")
oExplorer = oOutlook.Explorers.Add(oNameSpace.Folders[1],olFolderDisplayNormal)
oExplorer.Activate()

oMailItem = oOutlook.CreateItem( olMailItem )

WITH oMailItem

.To      = TRIM(emaillog.to_address)
.Subject = TRIM(emaillog.subject)+thisform.SubjectSuffix
.Body    = "Completed log file: "+thisform.LogFileURL
.Save()
*!* .Send()  && does not allow me to Send

ENDWITH 
IF lc_WasOutLookOpen = .F.
   oOutlook.Quit
ENDIF   




Dan B.





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