Author: MB Software Solutions, LLC
Posted: 2019-08-20 23:22:06 Link
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
_______________________________________________
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/97df0ecb-3a02-ecac-cd8a-77c01fff64aa@mbsoftwaresolutions.com
** 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.
Author: Kurt @ Gmail
Posted: 2019-08-21 01:22:59 Link
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]
_______________________________________________
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/f9d0f93d-a5d4-bf83-9bb9-1f8020a07f17@gmail.com
** 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.
Author: John Weller
Posted: 2019-08-21 01:58:18 Link
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]
_______________________________________________
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/9D2C6CA9-27B9-4156-9CA5-8E3CDABB506D@johnweller.co.uk
** 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.
Author: Koen Piller
Posted: 2019-08-21 02:10:24 Link
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]
_______________________________________________
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/CACUu1StxaaQXbKrAF_VzmAoU0GyaJ9_DmK_TsdL1NxYJUV87Rw@mail.gmail.com
** 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.
Author: Alan Bourke
Posted: 2019-08-21 03:17:04 Link
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.
--
Alan Bourke
alanpbourke (at) fastmail (dot) fm
On Wed, 21 Aug 2019, at 5:22 AM, 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]
_______________________________________________
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/b041d48b-be2d-452f-94e7-595cf45419df@www.fastmail.com
** 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.
Author: Alan Bourke
Posted: 2019-08-21 03:17:04 Link
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.
--
Alan Bourke
alanpbourke (at) fastmail (dot) fm
On Wed, 21 Aug 2019, at 5:22 AM, 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]
_______________________________________________
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/b041d48b-be2d-452f-94e7-595cf45419df@www.fastmail.com
** 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.
Author: Frank Cazabon
Posted: 2019-08-21 06:40:42 Link
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.
>
>
>
_______________________________________________
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/846fca74-7d65-c745-5c26-51197748a4e9@gmail.com
** 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.
Author: Ted Roche
Posted: 2019-08-21 08:37:23 Link
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
--
Ted Roche
Ted Roche & Associates, LLC
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
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/CACW6n4vnOj5KqWdiha55mAt=Fv+w9HibSCLznMw=VTAY2-qu8g@mail.gmail.com
** 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.
Author: Malcolm Greene
Posted: 2019-08-21 08:58:05 Link
Michael,
A better option than Outlook (ugh!): Check out SendGrid (now part of Twilio).
Malcolm
_______________________________________________
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/dd267b5b-f5ff-49f6-bf15-0c4ff0c3dee8@www.fastmail.com
** 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.
Author: Richard Kaye
Posted: 2019-08-21 09:42:00 Link
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.
_______________________________________________
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/BN6PR10MB1458EFFD3FDB7EF521E783CED2AA0@BN6PR10MB1458.namprd10.prod.outlook.com
** 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.