System.Net.Mail Method

I'm thinking about using this method (System.Net.Mail Method) to send out email from within a customer Application.  Is there a way to determine which version of PowerShell is needed to run the code?  Is there any danger of this method being replaced down the road.

Thanks,

Kevin

July 6th, 2015 1:38pm

Hi Kevin,

As long as you're running at least v2 you can just use Send-MailMessage.

http://ss64.com/ps/send-mailmessage.html

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 1:41pm

Hi Mike,

I can't use Send-MailMessage because I need authentication and TLS (will allow my customers to send mail through their Gmail, Yahoo, AOL, etc accounts).

July 6th, 2015 1:49pm

If you're v3+ you can do that with Send-MailMessage. If not, you can also check this:

https://gallery.technet.microsoft.com/Send-MailMessage-3a920a6d

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 2:07pm

I'm using PS within my application, which will run on my customers computer, so I don't know what they will have, I'm thinking at least v2, but I also didn't want to write a script where the commands (method) may be close to being replaced with something else
July 6th, 2015 2:18pm

Send-MailMessage in all versions of PowerShell V2 and later sends TLS mail.  Each service, like gmail, defines a separate port for this.  Only V and later will allow you to choose the port. As best I can remember if Net V3 is not installed then you cannot use TLS.

If you use Send-MailMessage  with V2 it will use port 25 and negotiate TLS although I haven't tested that exact variation.

Since PowerShell V2 RTM is no longer supported I recommend coding to WMF 3.0.

I guarantee you that you will not find any solution that works in all systems.

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 2:31pm

jrv-

I know what you mean about no perfect solution, but if I could at least have the info to tell them upfront they will need this and that to use the email feature, that will be the best I can hope for.  

Thanks,

Kevin

July 6th, 2015 2:59pm

Every email provider has variations when it comes to TLS.  Outlook can and will negotiate but must be given a correct port.  Net.Mail will negotiate if Net V3 or later I believe.

There is no blanket solution and I know of no one who has a chart of providers.

Sorry.

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 3:38pm

right, I'm not trying to provide the info for them, I've got a form that asks them this info, it's up to the end user to find out what their provider requires, I just wanted to make sure someone running Vista - Win 10 could send mail, but if Net.Mail is on the blocks for replacement, I don't want to waste time writing code that will change in a year.
July 6th, 2015 8:32pm

The issue is not Net.Mail.  It is the email providers and the version of Net.Mail. Alao PowerShell V2 does not support the latest version of Net.Mail.

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 8:43pm

There are four versions of Net.Mail:

2,3,3.5 and 4

July 6th, 2015 8:46pm

On the happier side all versions support explicit TLS.

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 8:50pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics