Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Sending eMails

Reply
 
Old 10-22-2006   #11 (permalink)
Matt Hamilton


 
 

Re: Sending eMails

Jim Holbach wrote:

> 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".


Eh? Is this something you've set up for yourself, Jim? There's no "MSDN"
function in my shell:

Method invocation failed because [System.Net.Mail.SmtpClient] doesn't
contain a method named 'MSDN'.
At line:1 char:8
+ $a.MSDN( <<<< )

My System SpecsSystem Spec
Old 10-22-2006   #12 (permalink)
Jim Holbach


 
 

Re: Sending eMails

Sorry. I've gotten so used to using this method, I forgot it was a type
extension that Jeffrey Snover posted at
http://blogs.msdn.com/powershell/arc...24/644987.aspx.

"Matt Hamilton" wrote:

> Jim Holbach wrote:
>
> > 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".

>
> Eh? Is this something you've set up for yourself, Jim? There's no "MSDN"
> function in my shell:
>
> Method invocation failed because [System.Net.Mail.SmtpClient] doesn't
> contain a method named 'MSDN'.
> At line:1 char:8
> + $a.MSDN( <<<< )
>

My System SpecsSystem Spec
Old 10-23-2006   #13 (permalink)
Fabio GRANDE poker.it>


 
 

Re: Sending eMails

Here's the code...

# First, I instantiate the SmtpClient object...
$Mailer = new-object Net.Mail.SmtpClient("mail.server.it")
# Then, I instantiate a new MailMessage object, with sender, destination,
subject and body
$Message = new-object Net.Mail.MailMessage("f.grande@poker.it",
"f.grande@poker.it", "Subject", "Here is some mail from PowerShell.")
# I create a new Attachment object
$Attach = new-object Net.Mail.Attachment("c:\\bell.ico")
# I attach the attachment to the message
$Message.Attachments.Add($Attach)
# Send them all...
$Mailer.Send($Message)


Hope it helps...
Bye
My System SpecsSystem Spec
Old 10-23-2006   #14 (permalink)
Fabio GRANDE poker.it>


 
 

Re: Sending eMails

Hi mabster, just a question...


new-object Net.Mail.SmtpClient -arg "mailserver.example.com"

is the same of

new-object Net.Mail.SmtpClient("mailserver.example.com")

?!?!?!?!?!

TIA
FabioG

My System SpecsSystem Spec
Old 10-23-2006   #15 (permalink)
mabster


 
 

Re: Sending eMails

Fabio GRANDE poker.it> <f.grande wrote:
> Hi mabster, just a question...
>
> new-object Net.Mail.SmtpClient -arg "mailserver.example.com"
>
> is the same of
>
> new-object Net.Mail.SmtpClient("mailserver.example.com")


Does that work? (tries) Yeah, it does. How 'bout that?

Yeah, that's the same thing then, Fabio. Not sure why both syntaxes are
supported. The former feels a bit more "PowerShelly" if you know what I
mean.
My System SpecsSystem Spec
Old 10-23-2006   #16 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: Sending eMails


"mabster" <mabster@madprops.nospam.org> wrote in message
news:%23mYs5dn9GHA.2364@TK2MSFTNGP02.phx.gbl...
> Fabio GRANDE poker.it> <f.grande wrote:
>> Hi mabster, just a question...
>>
>> new-object Net.Mail.SmtpClient -arg "mailserver.example.com"
>>
>> is the same of new-object Net.Mail.SmtpClient("mailserver.example.com")

>
> Does that work? (tries) Yeah, it does. How 'bout that?
>
> Yeah, that's the same thing then, Fabio. Not sure why both syntaxes are
> supported. The former feels a bit more "PowerShelly" if you know what I
> mean.


Those are actually the same form; you're just seeing PowerShell treating
argument separation intelligently (but obscurely). The second example is
really see as:
new-object Net.Mail.SmtpClient ("mailserver.example.com")

Here's a quick demonstration to prove it:

PS> function test{param($one,$two);write-host $one; write-host $two;}
PS> test 1(2)
1
2

Note that classes such as this with simple constructors can be instantiated
even more easily:

[Net.Mail.SmtpClient]"mailserver.example.com"


My System SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46