VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
What's the BEST (and hopefully easiest) way to implement this? Invoke Outlook via CREATEOBJECT and set properties and attachments accordingly? Typically in the past I've used MAILTO and ShellExec but this time the extra requirement is to have files attached from the application too, which makes MAILTO not an option, if I understand correctly.
tia, --Mike
--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
Wow - Deja vu!
I joined this forum Circa 2008 - and, previously I was at a job and had to do Exactly this! It was maybe circa 2005-06. YEs, I did indeed do this via Office Automation. There was a great book out there - all about doing OA - and that's how I ended up doing the project. I too needed to do attachments as well.
Book w/all answers is by Hentzenwerks (probably misspelled that!). But, there you have it...
-K-
On 8/20/2019 9:22 PM, MB Software Solutions, LLC wrote:
VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
What's the BEST (and hopefully easiest) way to implement this? Invoke Outlook via CREATEOBJECT and set properties and attachments accordingly? Typically in the past I've used MAILTO and ShellExec but this time the extra requirement is to have files attached from the application too, which makes MAILTO not an option, if I understand correctly.
tia, --Mike
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
[excessive quoting removed by server]
I use CDO to do just that. I’m not in the office until later today but when I get in I’ll send you some sample code if you wish?
John
John Weller 01380 723235 079763 93631 Sent from my iPad
On 21 Aug 2019, at 05:22, MB Software Solutions, LLC mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
What's the BEST (and hopefully easiest) way to implement this? Invoke Outlook via CREATEOBJECT and set properties and attachments accordingly? Typically in the past I've used MAILTO and ShellExec but this time the extra requirement is to have files attached from the application too, which makes MAILTO not an option, if I understand correctly.
tia, --Mike
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
[excessive quoting removed by server]
If your client is not using Gmail than VFPWinsock is the easiest app to mail with attachments Koen
Op wo 21 aug. 2019 om 08:58 schreef John Weller john@johnweller.co.uk
I use CDO to do just that. I’m not in the office until later today but when I get in I’ll send you some sample code if you wish?
John
John Weller 01380 723235 079763 93631 Sent from my iPad
On 21 Aug 2019, at 05:22, MB Software Solutions, LLC <
mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:
VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given
email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
What's the BEST (and hopefully easiest) way to implement this? Invoke
Outlook via CREATEOBJECT and set properties and attachments accordingly? Typically in the past I've used MAILTO and ShellExec but this time the extra requirement is to have files attached from the application too, which makes MAILTO not an option, if I understand correctly.
tia, --Mike
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
[excessive quoting removed by server]
This client is using OUTLOOK, not Gmail.
On 8/21/2019 3:10 AM, Koen Piller wrote:
If your client is not using Gmail than VFPWinsock is the easiest app to mail with attachments Koen
Op wo 21 aug. 2019 om 08:58 schreef John Weller john@johnweller.co.uk
I use CDO to do just that. I’m not in the office until later today but when I get in I’ll send you some sample code if you wish?
John
John Weller 01380 723235 079763 93631 Sent from my iPad
On 21 Aug 2019, at 05:22, MB Software Solutions, LLC <
mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:
VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given
email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
What's the BEST (and hopefully easiest) way to implement this? Invoke
Outlook via CREATEOBJECT and set properties and attachments accordingly? Typically in the past I've used MAILTO and ShellExec but this time the extra requirement is to have files attached from the application too, which makes MAILTO not an option, if I understand correctly.
tia, --Mike
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
[excessive quoting removed by server]
If you want to use Outlook:
loOutlook=CreateObject("Outlook.Application") loMsg = loOutlook.CreateItem(0) loMsg.BodyFormat= 2 && olFormatHTML loMsg.HtmlBody="<p>HTML body text</p>" loMsg.Body = "Plain body text for clients without HTML mail support." loMsg.Subject="Subject" loMsg.Recipients.Add("someguy@somewhere.com") loMsg.Recipients.Add("somegal@anotherplace.com") loMsg.Attachments.Add("attach1.txt", 1) loMsg.Attachments.Add("attach2.txt", 1) loMsg.Attachments.Add("attach3.txt", 1)
Try llSent = loMsg.Send() Catch to loException && handle it Finally release loMsg release loOutlook Endtry
HOWEVER
There are some drawbacks to this.
- Despite it sending via Outlook, you will find that any Outlook signatures or stationery that would normally apply won't get used on the programmatically created message.
- You may find that the dread Outlook security message ('A program is trying to send mail on your behalf...') will crop up, depending on Outlook and Exchange Server version.
Mike,
along with Alan's code you can use loMsg.Display() to display the email on screen before sending.
Frank.
Frank Cazabon
On 21/08/2019 04:17 AM, Alan Bourke wrote:
If you want to use Outlook:
loOutlook=CreateObject("Outlook.Application") loMsg = loOutlook.CreateItem(0) loMsg.BodyFormat= 2 && olFormatHTML loMsg.HtmlBody="<p>HTML body text</p>" loMsg.Body = "Plain body text for clients without HTML mail support." loMsg.Subject="Subject" loMsg.Recipients.Add("someguy@somewhere.com") loMsg.Recipients.Add("somegal@anotherplace.com") loMsg.Attachments.Add("attach1.txt", 1) loMsg.Attachments.Add("attach2.txt", 1) loMsg.Attachments.Add("attach3.txt", 1)
Try llSent = loMsg.Send() Catch to loException && handle it Finally release loMsg release loOutlook Endtry
HOWEVER
There are some drawbacks to this.
Despite it sending via Outlook, you will find that any Outlook signatures or stationery that would normally apply won't get used on the programmatically created message.
You may find that the dread Outlook security message ('A program is trying to send mail on your behalf...') will crop up, depending on Outlook and Exchange Server version.
Yes, thanks...spec calls for user to review everything and they have the responsibility to press Send...the app will not auto-send it.
On 8/21/2019 7:40 AM, Frank Cazabon wrote:
Mike,
along with Alan's code you can use loMsg.Display() to display the email on screen before sending.
Frank.
Frank Cazabon
On 21/08/2019 04:17 AM, Alan Bourke wrote:
If you want to use Outlook:
loOutlook=CreateObject("Outlook.Application") loMsg = loOutlook.CreateItem(0) loMsg.BodyFormat= 2 && olFormatHTML loMsg.HtmlBody="<p>HTML body text</p>" loMsg.Body = "Plain body text for clients without HTML mail support." loMsg.Subject="Subject" loMsg.Recipients.Add("someguy@somewhere.com") loMsg.Recipients.Add("somegal@anotherplace.com") loMsg.Attachments.Add("attach1.txt", 1) loMsg.Attachments.Add("attach2.txt", 1) loMsg.Attachments.Add("attach3.txt", 1)
Try llSent = loMsg.Send() Catch to loException && handle it Finally release loMsg release loOutlook Endtry
HOWEVER
There are some drawbacks to this.
- Despite it sending via Outlook, you will find that any Outlook
signatures or stationery that would normally apply won't get used on the programmatically created message.
- You may find that the dread Outlook security message ('A program is
trying to send mail on your behalf...') will crop up, depending on Outlook and Exchange Server version.
[excessive quoting removed by server]
On Wed, Aug 21, 2019 at 12:22 AM MB Software Solutions, LLC < mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:
VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
Despite its advanced age (16!) this paper still has a few good pointers in it:
https://www.tedroche.com/Present/2003/OutlookAutomation.html
"However, just because you can do something doesn't mean that you should. " made me laugh.
The canonical reference is Office Automation with Visual FoxPro by Tamar E. Granor and Della Martin, edited by yours truly, and more info can be found at:
http://hentzenwerke.com/catalog/autofox.htm
Note that there are sample chapters and downloads available. The site says "Out of Print" but I think the ebook may still be order-able.
Bear in mind that MSFT regularly changes and breaks their APIs, or the mechanism to access the APIs, since skript kiddies regularly take over Outlook and use it to send spam and perpetrate identity theft. Just in the last month's patches, they broke portions of VB6, VBA and VBScript. I shipped a number of apps with Office Automation back in the day, and between Office object model changes and security enhancements required some major rewriting, sometimes sprung on us by surprise. It was a learning experience in how Microsoft supports developers of their products.
Rather than tightly coupling your VFP app with this week's version of Outlook, you might consider how an arm's length relationship could work out better for all involved. You could use WestWind Client Tools, BLAT, or command-line mail tools [1] to draft the message and send it to the customer, who could review it and forward it to the client, with the downside they would need to specify the forwarding address, or you could write a .NET app integrated into Outlook that could read a queue written into a database table by FoxPro and do the automation and processing in .NET.
And remember, kids, MAPI Bad! SMTP Good. Just Say No. We Can Eliminate It In Our Lifetimes.
Good luck!
[1] I also wrote a white paper "Email Without Outlook" for this very reason: https://www.tedroche.com/Present/2002/emailwooutlook.html
Michael,
A better option than Outlook (ugh!): Check out SendGrid (now part of Twilio).
Malcolm
A better option than Outlook (ugh!): Check out SendGrid (now part of Twilio).
SendGrid, MailJet et al are definitely the way to go for bulk emailing, however are possibly overkill for sending occasional one-off messages from an application, which is what I took the requirement to be.
"I'm already paying for Office 365, why am I paying for SendGrid on top to send a few emails?"
SendGrid, MailJet et al are definitely the way to go for bulk emailing, however are possibly overkill for sending occasional one-off messages from an application, which is what I took the requirement to be. "I'm already paying for Office 365, why am I paying for SendGrid on top to send a few emails?"
SendGrid free plan covers 100 emails/day.
Malcolm
On 8/21/2019 9:58 AM, Malcolm Greene wrote:
Michael,
A better option than Outlook (ugh!): Check out SendGrid (now part of Twilio).
Hi Malcolm,
But this customer--who uses Outlook currently--wants the email "prepped, ready, and shown" in Outlook so they can review and just press the Send button. Otherwise, yeah, I'd probably go a different way! ;-)
--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
I feel better now... 😊
--
rk
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Ted Roche Sent: Wednesday, August 21, 2019 9:37 AM To: profoxtech@leafe.com Subject: Re: Easiest/best way to create an email using local MS Outlook with file attachments?
<snip> And remember, kids, MAPI Bad! SMTP Good. Just Say No. We Can Eliminate It In Our Lifetimes.
As promised. This example uses a Gmail account.
lcErr = "" lcSchema = "http://schemas.microsoft.com/cdo/configuration/" loConfig = CREATEOBJECT("CDO.Configuration") WITH loConfig.FIELDS .ITEM(lcSchema + "smtpserver") = "smtp.gmail.com" .ITEM(lcSchema + "smtpserverport") = 465 && 465 or 587 .ITEM(lcSchema + "sendusing") = 2 .ITEM(lcSchema + "smtpauthenticate") = .T. .ITEM(lcSchema + "smtpusessl") = .T. .ITEM(lcSchema + "sendusername") = lcUserName .ITEM(lcSchema + "sendpassword") = lcPassword .UPDATE ENDWITH loMsg = CREATEOBJECT ("CDO.Message") WITH loMsg .Configuration = loConfig .FROM = lcFrom .TO = lcTo IF NOT EMPTY(lcCC) .CC = lcCC ENDIF IF NOT EMPTY(lcBCC) .BCC = lcBCC ENDIF .Subject = lcSubject .TextBody = lcText IF NOT EMPTY(lcAttach1) .AddAttachment(lcAttach1) ENDIF IF NOT EMPTY(lcAttach2) .AddAttachment(lcAttach2) ENDIF .Send() ENDWITH
HTH
John
John Weller 01380 723235 07976 393631
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of MB Software Solutions, LLC Sent: 21 August 2019 05:22 To: profoxtech@leafe.com Subject: Easiest/best way to create an email using local MS Outlook with file attachments?
VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
What's the BEST (and hopefully easiest) way to implement this? Invoke Outlook via CREATEOBJECT and set properties and attachments accordingly? Typically in the past I've used MAILTO and ShellExec but this time the extra requirement is to have files attached from the application too, which makes MAILTO not an option, if I understand correctly.
tia, --Mike
--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
[excessive quoting removed by server]
Hi John,
Thanks for your code below. It's pretty much exactly what I use for my bug reporting where the app automatically sends an email. However, in this case, the customer WANTS to see it in Outlook and review it themselves before pressing the Send button to email it. (Paranoia?)
Thanks though.
On 8/21/2019 11:19 AM, John Weller wrote:
As promised. This example uses a Gmail account.
lcErr = "" lcSchema = "http://schemas.microsoft.com/cdo/configuration/" loConfig = CREATEOBJECT("CDO.Configuration") WITH loConfig.FIELDS .ITEM(lcSchema + "smtpserver") = "smtp.gmail.com" .ITEM(lcSchema + "smtpserverport") = 465 && 465 or 587 .ITEM(lcSchema + "sendusing") = 2 .ITEM(lcSchema + "smtpauthenticate") = .T. .ITEM(lcSchema + "smtpusessl") = .T. .ITEM(lcSchema + "sendusername") = lcUserName .ITEM(lcSchema + "sendpassword") = lcPassword .UPDATE ENDWITH loMsg = CREATEOBJECT ("CDO.Message") WITH loMsg .Configuration = loConfig .FROM = lcFrom .TO = lcTo IF NOT EMPTY(lcCC) .CC = lcCC ENDIF IF NOT EMPTY(lcBCC) .BCC = lcBCC ENDIF .Subject = lcSubject .TextBody = lcText IF NOT EMPTY(lcAttach1) .AddAttachment(lcAttach1) ENDIF IF NOT EMPTY(lcAttach2) .AddAttachment(lcAttach2) ENDIF .Send() ENDWITH
HTH
John
John Weller 01380 723235 07976 393631
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of MB Software Solutions, LLC Sent: 21 August 2019 05:22 To: profoxtech@leafe.com Subject: Easiest/best way to create an email using local MS Outlook with file attachments?
VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
What's the BEST (and hopefully easiest) way to implement this? Invoke Outlook via CREATEOBJECT and set properties and attachments accordingly? Typically in the past I've used MAILTO and ShellExec but this time the extra requirement is to have files attached from the application too, which makes MAILTO not an option, if I understand correctly.
tia, --Mike
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
[excessive quoting removed by server]
So maybe make the loMsg object visible and don’t invoke the Send() method?
--
rk
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of MB Software Solutions, LLC Sent: Wednesday, August 21, 2019 5:31 PM To: profoxtech@leafe.com Subject: Re: Easiest/best way to create an email using local MS Outlook with file attachments?
Hi John,
Thanks for your code below. It's pretty much exactly what I use for my bug reporting where the app automatically sends an email. However, in this case, the customer WANTS to see it in Outlook and review it themselves before pressing the Send button to email it. (Paranoia?)
Thanks though.
On 8/21/2019 11:19 AM, John Weller wrote:
As promised. This example uses a Gmail account.
lcErr = "" lcSchema = "http://schemas.microsoft.com/cdo/configuration/" loConfig = CREATEOBJECT("CDO.Configuration") WITH loConfig.FIELDS .ITEM(lcSchema + "smtpserver") = "smtp.gmail.com" .ITEM(lcSchema + "smtpserverport") = 465 && 465 or 587 .ITEM(lcSchema + "sendusing") = 2 .ITEM(lcSchema + "smtpauthenticate") = .T. .ITEM(lcSchema + "smtpusessl") = .T. .ITEM(lcSchema + "sendusername") = lcUserName .ITEM(lcSchema + "sendpassword") = lcPassword .UPDATE ENDWITH loMsg = CREATEOBJECT ("CDO.Message") WITH loMsg .Configuration = loConfig .FROM = lcFrom .TO = lcTo IF NOT EMPTY(lcCC) .CC = lcCC ENDIF IF NOT EMPTY(lcBCC) .BCC = lcBCC ENDIF .Subject = lcSubject .TextBody = lcText IF NOT EMPTY(lcAttach1) .AddAttachment(lcAttach1) ENDIF IF NOT EMPTY(lcAttach2) .AddAttachment(lcAttach2) ENDIF .Send() ENDWITH
HTH
John
John Weller 01380 723235 07976 393631
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of MB Software Solutions, LLC Sent: 21 August 2019 05:22 To: profoxtech@leafe.com Subject: Easiest/best way to create an email using local MS Outlook with file attachments?
VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
What's the BEST (and hopefully easiest) way to implement this? Invoke Outlook via CREATEOBJECT and set properties and attachments accordingly? Typically in the past I've used MAILTO and ShellExec but this time the extra requirement is to have files attached from the application too, which makes MAILTO not an option, if I understand correctly.
tia, --Mike
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
[excessive quoting removed by server]
_______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: https://leafe.com/archives This message: https://leafe.com/archives/byMID/8ea12cd3-ac5d-950d-bdbf-eb041e691efe@mbsoft... ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious. Report [OT] Abuse: http://leafe.com/reportAbuse/8ea12cd3-ac5d-950d-bdbf-eb041e691efe@mbsoftware...
Well that answer sounds like the obvious easy answer but I kinda thought that using this component was all for a seamless emailing and did not have a visible component. I'll test that out and report back. Basically, I thought there was no visible email client with this approach?
On 8/21/2019 5:35 PM, Richard Kaye wrote:
So maybe make the loMsg object visible and don’t invoke the Send() method?
--
rk
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of MB Software Solutions, LLC Sent: Wednesday, August 21, 2019 5:31 PM To: profoxtech@leafe.com Subject: Re: Easiest/best way to create an email using local MS Outlook with file attachments?
Hi John,
Thanks for your code below. It's pretty much exactly what I use for my bug reporting where the app automatically sends an email. However, in this case, the customer WANTS to see it in Outlook and review it themselves before pressing the Send button to email it. (Paranoia?)
Thanks though.
On 8/21/2019 11:19 AM, John Weller wrote:
As promised. This example uses a Gmail account.
lcErr = "" lcSchema = "http://schemas.microsoft.com/cdo/configuration/" loConfig = CREATEOBJECT("CDO.Configuration") WITH loConfig.FIELDS .ITEM(lcSchema + "smtpserver") = "smtp.gmail.com" .ITEM(lcSchema + "smtpserverport") = 465 && 465 or 587 .ITEM(lcSchema + "sendusing") = 2 .ITEM(lcSchema + "smtpauthenticate") = .T. .ITEM(lcSchema + "smtpusessl") = .T. .ITEM(lcSchema + "sendusername") = lcUserName .ITEM(lcSchema + "sendpassword") = lcPassword .UPDATE ENDWITH loMsg = CREATEOBJECT ("CDO.Message") WITH loMsg .Configuration = loConfig .FROM = lcFrom .TO = lcTo IF NOT EMPTY(lcCC) .CC = lcCC ENDIF IF NOT EMPTY(lcBCC) .BCC = lcBCC ENDIF .Subject = lcSubject .TextBody = lcText IF NOT EMPTY(lcAttach1) .AddAttachment(lcAttach1) ENDIF IF NOT EMPTY(lcAttach2) .AddAttachment(lcAttach2) ENDIF .Send() ENDWITH
HTH
John
John Weller 01380 723235 07976 393631
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of MB Software Solutions, LLC Sent: 21 August 2019 05:22 To: profoxtech@leafe.com Subject: Easiest/best way to create an email using local MS Outlook with file attachments?
VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
What's the BEST (and hopefully easiest) way to implement this? Invoke Outlook via CREATEOBJECT and set properties and attachments accordingly? Typically in the past I've used MAILTO and ShellExec but this time the extra requirement is to have files attached from the application too, which makes MAILTO not an option, if I understand correctly.
tia, --Mike
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
[excessive quoting removed by server]
Always start with the simplest solution is my motto... 😊
I've never automated CDO objects so don't have a clue. Should be easy enough to find out if the message object has a UI. If not, you'd need to go with automating Outlook instead of using CDO.
--
rk
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of MB Software Solutions, LLC Sent: Thursday, August 22, 2019 12:32 AM To: profoxtech@leafe.com Subject: Re: Easiest/best way to create an email using local MS Outlook with file attachments?
Well that answer sounds like the obvious easy answer but I kinda thought that using this component was all for a seamless emailing and did not have a visible component. I'll test that out and report back. Basically, I thought there was no visible email client with this approach?
On 8/21/2019 5:35 PM, Richard Kaye wrote:
So maybe make the loMsg object visible and don’t invoke the Send() method?
--
rk
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of MB Software Solutions, LLC Sent: Wednesday, August 21, 2019 5:31 PM To: profoxtech@leafe.com Subject: Re: Easiest/best way to create an email using local MS Outlook with file attachments?
Hi John,
Thanks for your code below. It's pretty much exactly what I use for my bug reporting where the app automatically sends an email. However, in this case, the customer WANTS to see it in Outlook and review it themselves before pressing the Send button to email it. (Paranoia?)
Thanks though.
On 8/21/2019 11:19 AM, John Weller wrote:
As promised. This example uses a Gmail account.
lcErr = "" lcSchema = "http://schemas.microsoft.com/cdo/configuration/" loConfig = CREATEOBJECT("CDO.Configuration") WITH loConfig.FIELDS .ITEM(lcSchema + "smtpserver") = "smtp.gmail.com" .ITEM(lcSchema + "smtpserverport") = 465 && 465 or 587 .ITEM(lcSchema + "sendusing") = 2 .ITEM(lcSchema + "smtpauthenticate") = .T. .ITEM(lcSchema + "smtpusessl") = .T. .ITEM(lcSchema + "sendusername") = lcUserName .ITEM(lcSchema + "sendpassword") = lcPassword .UPDATE ENDWITH loMsg = CREATEOBJECT ("CDO.Message") WITH loMsg .Configuration = loConfig .FROM = lcFrom .TO = lcTo IF NOT EMPTY(lcCC) .CC = lcCC ENDIF IF NOT EMPTY(lcBCC) .BCC = lcBCC ENDIF .Subject = lcSubject .TextBody = lcText IF NOT EMPTY(lcAttach1) .AddAttachment(lcAttach1) ENDIF IF NOT EMPTY(lcAttach2) .AddAttachment(lcAttach2) ENDIF .Send() ENDWITH
HTH
John
John Weller 01380 723235 07976 393631
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of MB Software Solutions, LLC Sent: 21 August 2019 05:22 To: profoxtech@leafe.com Subject: Easiest/best way to create an email using local MS Outlook with file attachments?
VFP9SP2 app
Customer uses Outlook and wants the app to generate an email to a given email address from the app AND attach certain documents to it. Customer will preview it and then manually hit "Send" on their own.
What's the BEST (and hopefully easiest) way to implement this? Invoke Outlook via CREATEOBJECT and set properties and attachments accordingly? Typically in the past I've used MAILTO and ShellExec but this time the extra requirement is to have files attached from the application too, which makes MAILTO not an option, if I understand correctly.
tia, --Mike
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
[excessive quoting removed by server]
_______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: https://leafe.com/archives This message: https://leafe.com/archives/byMID/22502d2b-c346-23f5-2bae-b54af680b93a@mbsoft... ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious. Report [OT] Abuse: http://leafe.com/reportAbuse/22502d2b-c346-23f5-2bae-b54af680b93a@mbsoftware...
The thing about CDO is that it's deprecated by Microsoft and not supported on anything after Outlook 2010 as far as I can tell.