Index
2016-03-30 06:02Laurie Alvey : Email using .NET
2016-03-30 06:36Stephen Russell : Re: Email using .NET
2016-03-30 06:43Ted Roche : Re: Email using .NET
2016-03-30 06:54Thierry Nivelet : Re: Email using .NET
2016-03-30 07:07Laurie Alvey : Re: Email using .NET
2016-03-30 07:09Laurie Alvey : Re: Email using .NET
2016-03-30 07:17mbsoftwaresolutions@mbsoftwaresolutions.com: Re: Email using .NET
2016-03-30 07:25Alan Bourke : Re: Email using .NET
2016-03-30 07:55Stephen Russell : Re: Email using .NET
2016-03-30 07:59Laurie Alvey : Re: Email using .NET
Back to top
Email using .NET

Author: Laurie Alvey

Posted: 2016-03-30 06:02:17   Link

I currently use CDO to send email from my apps but I'm thinking of using a

.NET component to do it. I have little experience with .NET and none using

.NET Interop. I've got Visual Studio Express 14.0 and VFP 9.0 SP2 and would

appreciate any pointers.

Laurie

--- 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: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CAMvTR9dHacC2K+SCP3zybrWDVWw9Wfc8QjUT6w7DYL4PS7j6Nw@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.

©2016 Laurie Alvey
Back to top
Re: Email using .NET

Author: Stephen Russell

Posted: 2016-03-30 06:36:17   Link

This works with a legit user running it. It will need a using statement

but your IDE will help you and put it in.

void sendEmail(string strFrom

, string strTo

, string strSubject

, string strBody)

{

MailMessage objMailMessage = new MailMessage();

System.Net.NetworkCredential objSMTPUserInfo =

new System.Net.NetworkCredential();

SmtpClient objSmtpClient = new SmtpClient();

try

{

objMailMessage.From = new MailAddress(strFrom);

objMailMessage.To.Add(new MailAddress(strTo));

objMailMessage.Subject = strSubject;

objMailMessage.Body = strBody;

objSmtpClient = new SmtpClient("172.0.0.1"); /// Server IP

objSMTPUserInfo = new System.Net.NetworkCredential

("User name", "Password","Domain");

objSmtpClient.Credentials = objSMTPUserInfo;

objSmtpClient.UseDefaultCredentials = false;

objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

objSmtpClient.Send(objMailMessage);

}

catch (Exception ex)

{ throw ex; }

finally

{

objMailMessage = null;

objSMTPUserInfo = null;

objSmtpClient = null;

}

}

On Wed, Mar 30, 2016 at 6:02 AM, Laurie Alvey <trukker41@gmail.com> wrote:

> I currently use CDO to send email from my apps but I'm thinking of using a

> .NET component to do it. I have little experience with .NET and none using

> .NET Interop. I've got Visual Studio Express 14.0 and VFP 9.0 SP2 and would

> appreciate any pointers.

>

> Laurie

>

>

> --- StripMime Report -- processed MIME parts ---

> multipart/alternative

> text/plain (text body -- kept)

> text/html

> ---

>

[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: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CAJidMYKtoXBKgG9wxvJhZFUh3ry7T4POt4e508tY89ovo9hu9Q@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.

©2016 Stephen Russell
Back to top
Re: Email using .NET

Author: Ted Roche

Posted: 2016-03-30 06:43:04   Link

On Wed, Mar 30, 2016 at 7:02 AM, Laurie Alvey <trukker41@gmail.com> wrote:

> I currently use CDO to send email from my apps but I'm thinking of using a

> .NET component to do it.

May I ask, "Why?"

--

Ted Roche

Ted Roche & Associates, LLC

http://www.tedroche.com

_______________________________________________

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: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CACW6n4smCU3EsBk+Av9KAjOWz7Ueb4VLxbcQRZwjRnPmdziCTw@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.

©2016 Ted Roche
Back to top
Re: Email using .NET

Author: Thierry Nivelet

Posted: 2016-03-30 06:54:48   Link

I would bet: for SSL support

Thierry Nivelet

FoxInCloud

Give your VFP app a second life in the cloud

http://foxincloud.com/

Le 30/03/2016 13:43, Ted Roche a écrit :

> On Wed, Mar 30, 2016 at 7:02 AM, Laurie Alvey <trukker41@gmail.com> wrote:

>

>> I currently use CDO to send email from my apps but I'm thinking of using a

>> .NET component to do it.

> May I ask, "Why?"

>

_______________________________________________

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: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/56FBBE88.6000508@foxincloud.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.

©2016 Thierry Nivelet
Back to top
Re: Email using .NET

Author: Laurie Alvey

Posted: 2016-03-30 07:07:44   Link

Hi Ted,

The principal reason is that I've never got the delivery notification stuff

to work in CDO.

Laurie

On 30 March 2016 at 12:54, Thierry Nivelet <tnivelet@foxincloud.com> wrote:

> I would bet: for SSL support

>

> Thierry Nivelet

> FoxInCloud

> Give your VFP app a second life in the cloud

> http://foxincloud.com/

>

> Le 30/03/2016 13:43, Ted Roche a écrit :

>

>> On Wed, Mar 30, 2016 at 7:02 AM, Laurie Alvey <trukker41@gmail.com>

>> wrote:

>>

>> I currently use CDO to send email from my apps but I'm thinking of using a

>>> .NET component to do it.

>>>

>> May I ask, "Why?"

>>

>>

>

[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: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CAMvTR9dsUaSkqmo-Lh-zogJ3u-qwESSB6p-k38BQPQVKo-SzFg@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.

©2016 Laurie Alvey
Back to top
Re: Email using .NET

Author: Laurie Alvey

Posted: 2016-03-30 07:09:24   Link

Hi Stephen,

Thanks for that. How do I use that class from within VFP?

Laurie

On 30 March 2016 at 13:07, Laurie Alvey <trukker41@gmail.com> wrote:

> Hi Ted,

> The principal reason is that I've never got the delivery notification

> stuff to work in CDO.

>

> Laurie

>

> On 30 March 2016 at 12:54, Thierry Nivelet <tnivelet@foxincloud.com>

> wrote:

>

>> I would bet: for SSL support

>>

>> Thierry Nivelet

>> FoxInCloud

>> Give your VFP app a second life in the cloud

>> http://foxincloud.com/

>>

>> Le 30/03/2016 13:43, Ted Roche a écrit :

>>

>>> On Wed, Mar 30, 2016 at 7:02 AM, Laurie Alvey <trukker41@gmail.com>

>>> wrote:

>>>

>>> I currently use CDO to send email from my apps but I'm thinking of using

>>>> a

>>>> .NET component to do it.

>>>>

>>> May I ask, "Why?"

>>>

>>>

>>

[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: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CAMvTR9exxknnvHxGfFFC3NzfQjBVXB28vBZo3=v4OTrZEg3Dqg@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.

©2016 Laurie Alvey
Back to top
Re: Email using .NET

Author: mbsoftwaresolutions@mbsoftwaresolutions.com

Posted: 2016-03-30 07:17:14   Link

On 2016-03-30 07:43, Ted Roche wrote:

> On Wed, Mar 30, 2016 at 7:02 AM, Laurie Alvey <trukker41@gmail.com>

> wrote:

>

>> I currently use CDO to send email from my apps but I'm thinking of

>> using a

>> .NET component to do it.

>

> May I ask, "Why?"

+1!!!

"If it ain't broke, ..."

_______________________________________________

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: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/96d4289521bf64fb59bb35ddf776f1ed@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.

©2016 mbsoftwaresolutions@mbsoftwaresolutions.com
Back to top
Re: Email using .NET

Author: Alan Bourke

Posted: 2016-03-30 07:25:30   Link

On Wed, 30 Mar 2016, at 12:43 PM, Ted Roche wrote:

> On Wed, Mar 30, 2016 at 7:02 AM, Laurie Alvey <trukker41@gmail.com>

> wrote:

>

> > I currently use CDO to send email from my apps but I'm thinking of using a

> > .NET component to do it.

>

> May I ask, "Why?"

>

Well, CDO is tied to Exchange Server and to my mind is gradually being

deprecated.

To answer Laurie's question, I had a similar requirement recently and I

achieved it by writing a .NET solution that uses the System.Net.Mail

namespace and the SMTP functionality therein. It basically creates a

fairly 'flat' interface, i.e.

SmtpEmailer.AddAttachment(string)

SmtpEmailer.AddLinkedImage(string)

SmtpEmailer.AddRecipient(string, string, string)

SmtpEmailer.BuildImageTag(string, string)

SmtpEmailer.Dispose()

SmtpEmailer.Dispose(bool)

SmtpEmailer.SendMessage()

SmtpEmailer.SetBody(string)

SmtpEmailer.SetBodyFormat(string)

SmtpEmailer.SetCredentials(string, string, string)

SmtpEmailer.SetFrom(string, string)

SmtpEmailer.SetPriority(string)

SmtpEmailer.SetSubject(string)

SmtpEmailer.SmtpEmailer()

SmtpEmailer.StartMessage()

SmtpEmailer.BodyText

SmtpEmailer.EnableSSL

SmtpEmailer.ExceptionMessage

SmtpEmailer.LastException

SmtpEmailer.LastStatusCode

SmtpEmailer.Port

SmtpEmailer.Server

SmtpEmailer.StatusCode

SmtpEmailer.TimeoutSeconds

SmtpEmailer.Version

This handles HTML mail with inline images (and automatically generates a

text version too). Also SSL.

So that spits out a DLL, how do I use that from VFP? You could create a

COM wrapper for it, but that woudl then involve building an installer

and everything that entails.

What I do is use Rick Strahl's wwdotnetbridge class which allows the use

of .NET assemblies directly from VFP with no installation (other than

.NET 4.0 or later being present). This means 'xcopy' deployment and no

messing with COM. Given the .NET DLL above and the relevant files for

wwdotnetbridge in the same folder, you can just use this to send an

email from VFP:

DO wwDotNetBridge

LOCAL loBridge as wwDotNetBridge

loBridge = GetwwDotnetBridge()

loBridge.LoadAssembly("my_dotnet_smtp.dll") && -- The .NET

DLL

Local loW as my_dotnet_smtp.SmtpEmailer

loW = loBridge.CreateInstance("my_dotnet_smtp.SmtpEmailer")

loW.EnableSSL = .t.

loW.Port = 587

loW.Server = "my.smtpserver.com"

loW.SetCredentials("username", "password", "")

loW.StartMessage()

loW.AddRecipient("joe.bloggs@gmail.com", "Alan", "")

loW.SetSubject("Here's an email.")

loW.SetBodyFormat("HTML")

lcLogoCID = loW.AddLinkedImage("c:\temp\logo.jpg")

lcMyHTML = "<p>Title text</p>" + loW.BuildImageTag(lcLogoCID,

"logo")

loW.SetBody(lcMyHTML)

loW.SetPriority("HIGH")

loW.SetFrom("youremail@yourcompany.com", "Your Name")

try

if !loW.SendMessage()

? loW.ExceptionMessage

? loW.StatusCode

EndIf

Catch to loException

? loW.ExceptionMessage

? loW.StatusCode

Endtry

loBridge.Unload()

Release loBridge

_______________________________________________

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: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/1459340730.3223457.563514594.25C26138@webmail.messagingengine.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.

©2016 Alan Bourke
Back to top
Re: Email using .NET

Author: Stephen Russell

Posted: 2016-03-30 07:55:41   Link

For myself I just insert rows into a sql table for outbound mail. I have a

job that fires every 10 min to process any data there and I use SQL Mail as

the sending process. It all works the same way in the end.

But how to call this from VFP?

Create a dll that you register in your gac. You then go through the

standard steps to create an object from this dll and consume it's

functionality in VFP.

On Wed, Mar 30, 2016 at 7:07 AM, Laurie Alvey <trukker41@gmail.com> wrote:

> Hi Ted,

> The principal reason is that I've never got the delivery notification stuff

> to work in CDO.

>

> Laurie

>

> On 30 March 2016 at 12:54, Thierry Nivelet <tnivelet@foxincloud.com>

> wrote:

>

> > I would bet: for SSL support

> >

> > Thierry Nivelet

> > FoxInCloud

> > Give your VFP app a second life in the cloud

> > http://foxincloud.com/

> >

> > Le 30/03/2016 13:43, Ted Roche a écrit :

> >

> >> On Wed, Mar 30, 2016 at 7:02 AM, Laurie Alvey <trukker41@gmail.com>

> >> wrote:

> >>

> >> I currently use CDO to send email from my apps but I'm thinking of

> using a

> >>> .NET component to do it.

> >>>

> >> May I ask, "Why?"

> >>

> >>

> >

[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: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CAJidMYJ7-Usf+bofBVFW_A7PgkdznOnZaKjkYHLqNxDb3V5Ngw@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.

©2016 Stephen Russell
Back to top
Re: Email using .NET

Author: Laurie Alvey

Posted: 2016-03-30 07:59:40   Link

Thanks everyone.

Laurie

On 30 March 2016 at 13:55, Stephen Russell <srussell705@gmail.com> wrote:

> For myself I just insert rows into a sql table for outbound mail. I have a

> job that fires every 10 min to process any data there and I use SQL Mail as

> the sending process. It all works the same way in the end.

>

> But how to call this from VFP?

>

> Create a dll that you register in your gac. You then go through the

> standard steps to create an object from this dll and consume it's

> functionality in VFP.

>

>

>

>

> On Wed, Mar 30, 2016 at 7:07 AM, Laurie Alvey <trukker41@gmail.com> wrote:

>

> > Hi Ted,

> > The principal reason is that I've never got the delivery notification

> stuff

> > to work in CDO.

> >

> > Laurie

> >

> > On 30 March 2016 at 12:54, Thierry Nivelet <tnivelet@foxincloud.com>

> > wrote:

> >

> > > I would bet: for SSL support

> > >

> > > Thierry Nivelet

> > > FoxInCloud

> > > Give your VFP app a second life in the cloud

> > > http://foxincloud.com/

> > >

> > > Le 30/03/2016 13:43, Ted Roche a écrit :

> > >

> > >> On Wed, Mar 30, 2016 at 7:02 AM, Laurie Alvey <trukker41@gmail.com>

> > >> wrote:

> > >>

> > >> I currently use CDO to send email from my apps but I'm thinking of

> > using a

> > >>> .NET component to do it.

> > >>>

> > >> May I ask, "Why?"

> > >>

> > >>

> > >

[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: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CAMvTR9fKiNHkV+AMGbVovY5OfxXyhbVL8M-gnP5tHE-+SZYWpg@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.

©2016 Laurie Alvey