![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Sending eMails Hi all. I'm wondering if it's possible to send eMails directly from Powershell... Can You point me in the right direction ? TIA FabioG |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Sending eMails http://groups.google.de/group/micros...f5421e406925f0 -- greetings dreeschkind "Fabio GRANDE" wrote: > Hi all. > I'm wondering if it's possible to send eMails directly from Powershell... > > Can You point me in the right direction ? > > TIA > FabioG |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Sending eMails That seems a bit excessive. How about: (new-object Net.Mail.SmtpClient -arg "mailserver.example.com").Send("from@powershell.com", "to@example.com", "Subject", "Here is some mail from PowerShell.") dreeschkind wrote: > http://groups.google.de/group/micros...f5421e406925f0 > > -- > greetings > dreeschkind > > "Fabio GRANDE" wrote: > >> Hi all. >> I'm wondering if it's possible to send eMails directly from Powershell... >> >> Can You point me in the right direction ? >> >> TIA >> FabioG |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Sending eMails Very Good ! Thank You Matt... (I did some improvement to send also attachments...) Fabio G |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Sending eMails Matt, I found the .NET Framework Class Library references in the MSDN library for SmtpClient Class and SmtpClient.Send Method (MailMessage) . However, can you give me some hints on how you transform that documentation into the example you showed? Or is there another class that i missed? Thank you, Fred Jacobowitz Matt Hamilton wrote: > That seems a bit excessive. How about: > > (new-object Net.Mail.SmtpClient -arg > "mailserver.example.com").Send("from@powershell.com", "to@example.com", > "Subject", "Here is some mail from PowerShell.") |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Sending eMails No worries, Fred. The first step is creating an instance of SmptClient, and passing in a mail server name to its constructor. In C# that'd look like this: System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient("mailserver.example.com") .... but in PS it's: new-object Net.Mail.SmtpClient -arg "mailserver.example.com" (The -arg parameter of new-object is how we pass stuff into an object's constructor.) So once we have our object, we just want to call its Send method. In C# we'd do this: sc.Send("from@powershell.com", "to@example.com", "Subject", "Here is some mail from PowerShell."); .... but in PS we don't even need a variable - we can just use the instance inline by wrapping it in parentheses, like this: (new-object Net.Mail.SmtpClient -arg "mailserver.example.com").Send("from@powershell.com", "to@example.com", "Subject", "Here is some mail from PowerShell.") Note that I could have done it on two lines with a variable: $sc = new-object Net.Mail.SmtpClient -arg "mailserver.example.com" $sc.Send("from@powershell.com", "to@example.com", "Subject", "Here is some mail from PowerShell."); Does that help? Fred J. wrote: > Matt, > I found the .NET Framework Class Library references in the MSDN library > for SmtpClient Class and SmtpClient.Send Method (MailMessage) . > However, can you give me some hints on how you transform that > documentation into the example you showed? Or is there another class > that i missed? > > Thank you, > Fred Jacobowitz > > Matt Hamilton wrote: >> That seems a bit excessive. How about: >> >> (new-object Net.Mail.SmtpClient -arg >> "mailserver.example.com").Send("from@powershell.com", "to@example.com", >> "Subject", "Here is some mail from PowerShell.") > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Sending eMails mabster, Yes this does help. Too me the mystery was unmasking the public constructors in the send method. Now i see they are derived from .NET Framework Class Library MailMessage Constructor (String, String, String, String). I am new to the Net Framework but I finally found the overload list here http://msdn2.microsoft.com/en-us/lib...ilmessage.aspx and the declaration here http://msdn2.microsoft.com/en-us/library/5k0ddab0.aspx Is this the way to 'dope-out' everything in .Net? Now I am going to try to add an attachment. Fred J. mabster wrote: > No worries, Fred. > > The first step is creating an instance of SmptClient, and passing in a > mail server name to its constructor. In C# that'd look like this: > > System.Net.Mail.SmtpClient sc = new > System.Net.Mail.SmtpClient("mailserver.example.com") > > ... but in PS it's: > > new-object Net.Mail.SmtpClient -arg "mailserver.example.com" > > (The -arg parameter of new-object is how we pass stuff into an object's > constructor.) > > So once we have our object, we just want to call its Send method. In C# > we'd do this: > > sc.Send("from@powershell.com", "to@example.com", "Subject", "Here is > some mail from PowerShell."); > > ... but in PS we don't even need a variable - we can just use the > instance inline by wrapping it in parentheses, like this: > > (new-object Net.Mail.SmtpClient -arg > "mailserver.example.com").Send("from@powershell.com", "to@example.com", > "Subject", "Here is some mail from PowerShell.") > > Note that I could have done it on two lines with a variable: > > $sc = new-object Net.Mail.SmtpClient -arg "mailserver.example.com" > $sc.Send("from@powershell.com", "to@example.com", "Subject", "Here is > some mail from PowerShell."); > > Does that help? > > Fred J. wrote: > > Matt, > > I found the .NET Framework Class Library references in the MSDN library > > for SmtpClient Class and SmtpClient.Send Method (MailMessage) . > > However, can you give me some hints on how you transform that > > documentation into the example you showed? Or is there another class > > that i missed? > > > > Thank you, > > Fred Jacobowitz > > > > Matt Hamilton wrote: > >> That seems a bit excessive. How about: > >> > >> (new-object Net.Mail.SmtpClient -arg > >> "mailserver.example.com").Send("from@powershell.com", "to@example.com", > >> "Subject", "Here is some mail from PowerShell.") > > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Sending eMails Do Tell! Thanks, Fred Jacobowitz Fabio wrote: > Very Good ! > Thank You Matt... (I did some improvement to send also attachments...) > Fabio G |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Sending eMails msdn subscription is a good source of finding various classes and constructors. That is why i m now trying to move from vbscript to powershell. But at time, i still wonder whether i shld create small programs in pure ..net environment (eg vs2005), this is where i m struggling now ... "Fred J." <swim.instructor@gmail.com> wrote in message news:1161356541.004369.26930@i3g2000cwc.googlegroups.com... > mabster, > Yes this does help. Too me the mystery was unmasking the public > constructors in the send method. Now i see they are derived from .NET > Framework Class Library > MailMessage Constructor (String, String, String, String). I am new to > the Net Framework but I finally found the overload list here > http://msdn2.microsoft.com/en-us/lib...ilmessage.aspx > and the declaration here > http://msdn2.microsoft.com/en-us/library/5k0ddab0.aspx > > Is this the way to 'dope-out' everything in .Net? > > Now I am going to try to add an attachment. > > Fred J. > > > > mabster wrote: >> No worries, Fred. >> >> The first step is creating an instance of SmptClient, and passing in a >> mail server name to its constructor. In C# that'd look like this: >> >> System.Net.Mail.SmtpClient sc = new >> System.Net.Mail.SmtpClient("mailserver.example.com") >> >> ... but in PS it's: >> >> new-object Net.Mail.SmtpClient -arg "mailserver.example.com" >> >> (The -arg parameter of new-object is how we pass stuff into an object's >> constructor.) >> >> So once we have our object, we just want to call its Send method. In C# >> we'd do this: >> >> sc.Send("from@powershell.com", "to@example.com", "Subject", "Here is >> some mail from PowerShell."); >> >> ... but in PS we don't even need a variable - we can just use the >> instance inline by wrapping it in parentheses, like this: >> >> (new-object Net.Mail.SmtpClient -arg >> "mailserver.example.com").Send("from@powershell.com", "to@example.com", >> "Subject", "Here is some mail from PowerShell.") >> >> Note that I could have done it on two lines with a variable: >> >> $sc = new-object Net.Mail.SmtpClient -arg "mailserver.example.com" >> $sc.Send("from@powershell.com", "to@example.com", "Subject", "Here is >> some mail from PowerShell."); >> >> Does that help? >> >> Fred J. wrote: >> > Matt, >> > I found the .NET Framework Class Library references in the MSDN library >> > for SmtpClient Class and SmtpClient.Send Method (MailMessage) . >> > However, can you give me some hints on how you transform that >> > documentation into the example you showed? Or is there another class >> > that i missed? >> > >> > Thank you, >> > Fred Jacobowitz >> > >> > Matt Hamilton wrote: >> >> That seems a bit excessive. How about: >> >> >> >> (new-object Net.Mail.SmtpClient -arg >> >> "mailserver.example.com").Send("from@powershell.com", >> >> "to@example.com", >> >> "Subject", "Here is some mail from PowerShell.") >> > > |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Sending eMails Fred - Here's a couple ways I know of to ferret out info: PS> $a = new-object Net.Mail.SmtpClient PS> $a.send.OverloadDefinitions System.Void Send(String from, String recipients, String subject, String body) System.Void Send(MailMessage message) and PS> $a.MSDN() will open a separate browser window in the msdn2.microsoft.com site with the documentation for the class of the object. In this example, it opened "http://msdn2.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx". Hope this helps. --- Jim Holbach "Fred J." wrote: > mabster, > Yes this does help. Too me the mystery was unmasking the public > constructors in the send method. Now i see they are derived from .NET > Framework Class Library > MailMessage Constructor (String, String, String, String). I am new to > the Net Framework but I finally found the overload list here > http://msdn2.microsoft.com/en-us/lib...ilmessage.aspx > and the declaration here > http://msdn2.microsoft.com/en-us/library/5k0ddab0.aspx > > Is this the way to 'dope-out' everything in .Net? > > Now I am going to try to add an attachment. > > Fred J. > > > > mabster wrote: > > No worries, Fred. > > > > The first step is creating an instance of SmptClient, and passing in a > > mail server name to its constructor. In C# that'd look like this: > > > > System.Net.Mail.SmtpClient sc = new > > System.Net.Mail.SmtpClient("mailserver.example.com") > > > > ... but in PS it's: > > > > new-object Net.Mail.SmtpClient -arg "mailserver.example.com" > > > > (The -arg parameter of new-object is how we pass stuff into an object's > > constructor.) > > > > So once we have our object, we just want to call its Send method. In C# > > we'd do this: > > > > sc.Send("from@powershell.com", "to@example.com", "Subject", "Here is > > some mail from PowerShell."); > > > > ... but in PS we don't even need a variable - we can just use the > > instance inline by wrapping it in parentheses, like this: > > > > (new-object Net.Mail.SmtpClient -arg > > "mailserver.example.com").Send("from@powershell.com", "to@example.com", > > "Subject", "Here is some mail from PowerShell.") > > > > Note that I could have done it on two lines with a variable: > > > > $sc = new-object Net.Mail.SmtpClient -arg "mailserver.example.com" > > $sc.Send("from@powershell.com", "to@example.com", "Subject", "Here is > > some mail from PowerShell."); > > > > Does that help? > > > > Fred J. wrote: > > > Matt, > > > I found the .NET Framework Class Library references in the MSDN library > > > for SmtpClient Class and SmtpClient.Send Method (MailMessage) . > > > However, can you give me some hints on how you transform that > > > documentation into the example you showed? Or is there another class > > > that i missed? > > > > > > Thank you, > > > Fred Jacobowitz > > > > > > Matt Hamilton wrote: > > >> That seems a bit excessive. How about: > > >> > > >> (new-object Net.Mail.SmtpClient -arg > > >> "mailserver.example.com").Send("from@powershell.com", "to@example.com", > > >> "Subject", "Here is some mail from PowerShell.") > > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| SENDING EMAILS | Vista mail | |||
| Re: sending emails | Vista mail | |||
| sending emails | Vista mail | |||
| sending emails | Vista mail | |||
| Sending emails | Vista mail | |||