Windows Vista Forums

sending an email
  1. #1


    mmccormick Guest

    sending an email

    Hi, Can anyone tell me why this won't work for me?



    $smtp = new-object Net.Mail.SmtpClient(”localhost”)
    $smtp.Send(”myemail@xxxxxx”, “myemail@xxxxxx”, “test subjext”, “test
    body here”)


    Maybe I need a snap-in or something? Thank you!

      My System SpecsSystem Spec

  2. #2


    Karl Mitschke Guest

    Re: sending an email

    Hello mmccormick,

    > Hi, Can anyone tell me why this won't work for me?
    >
    > $smtp = new-object Net.Mail.SmtpClient(”localhost”)
    > $smtp.Send(”myemail@xxxxxx”, “myemail@xxxxxx”, “test subjext”,
    > “test body here”)
    >
    > Maybe I need a snap-in or something? Thank you!
    >
    Is your localhost an smtp server?

    from a command prompt, try this:

    telnet localhost 25

    If that works, you can try creating and sending an email from the ppompt:

    helo
    mail from: myemail@xxxxxx
    rcpt to: myemail@xxxxxx
    data
    test body here
    ..(enter a dot/period to end the data)
    quit




      My System SpecsSystem Spec

  3. #3


    mmccormick Guest

    Re: sending an email

    Thanks Karl. What if the localhost is SMTP but is not 25?

    "Karl Mitschke" wrote:

    > Hello mmccormick,
    >

    > > Hi, Can anyone tell me why this won't work for me?
    > >
    > > $smtp = new-object Net.Mail.SmtpClient(”localhost”)
    > > $smtp.Send(”myemail@xxxxxx”, “myemail@xxxxxx”, “test subjext”,
    > > “test body here”)
    > >
    > > Maybe I need a snap-in or something? Thank you!
    > >
    >
    > Is your localhost an smtp server?
    >
    > from a command prompt, try this:
    >
    > telnet localhost 25
    >
    > If that works, you can try creating and sending an email from the ppompt:
    >
    > helo
    > mail from: myemail@xxxxxx
    > rcpt to: myemail@xxxxxx
    > data
    > test body here
    > ..(enter a dot/period to end the data)
    > quit
    >
    >
    >
    >

      My System SpecsSystem Spec

  4. #4


    Karl Mitschke Guest

    Re: sending an email

    Hello mmccormick,

    Telent localhost <smtp port>

    > Thanks Karl. What if the localhost is SMTP but is not 25?
    >
    > "Karl Mitschke" wrote:
    >

    >> Hello mmccormick,
    >>

    >>> Hi, Can anyone tell me why this won't work for me?
    >>>
    >>> $smtp = new-object Net.Mail.SmtpClient(”localhost”)
    >>> $smtp.Send(”myemail@xxxxxx”, “myemail@xxxxxx”, “test subjext”,
    >>> “test body here”)
    >>>
    >>> Maybe I need a snap-in or something? Thank you!
    >>>
    >> Is your localhost an smtp server?
    >>
    >> from a command prompt, try this:
    >>
    >> telnet localhost 25
    >>
    >> If that works, you can try creating and sending an email from the
    >> ppompt:
    >>
    >> helo
    >> mail from: myemail@xxxxxx
    >> rcpt to: myemail@xxxxxx
    >> data
    >> test body here
    >> ..(enter a dot/period to end the data)
    >> quit


      My System SpecsSystem Spec

  5. #5


    Shay Levy [MVP] Guest

    Re: sending an email

    Hi mmccormick,


    You can use the SmtpClient(server, port) overload and set the server/port:

    $smtp = new-object Net.Mail.SmtpClient(localhost,<portNumber>)

    or set it later:

    $smtp.port = <portNumber>


    ---
    Shay Levy
    Windows PowerShell MVP
    http://blogs.microsoft.co.il/blogs/ScriptFanatic
    PowerShell Toolbar: http://tinyurl.com/PSToolbar



    m> Thanks Karl. What if the localhost is SMTP but is not 25?
    m>
    m> "Karl Mitschke" wrote:
    m>

    >> Hello mmccormick,
    >>

    >>> Hi, Can anyone tell me why this won't work for me?
    >>>
    >>> $smtp = new-object Net.Mail.SmtpClient(localhost)
    >>> $smtp.Send(myemail@xxxxxx, myemail@xxxxxx, test subjext,
    >>> test body here)
    >>>
    >>> Maybe I need a snap-in or something? Thank you!
    >>>
    >> Is your localhost an smtp server?
    >>
    >> from a command prompt, try this:
    >>
    >> telnet localhost 25
    >>
    >> If that works, you can try creating and sending an email from the
    >> ppompt:
    >>
    >> helo
    >> mail from: myemail@xxxxxx
    >> rcpt to: myemail@xxxxxx
    >> data
    >> test body here
    >> ..(enter a dot/period to end the data)
    >> quit


      My System SpecsSystem Spec

  6. #6


    mmccormick Guest

    Re: sending an email

    This isn't working for me so I just don't know enough about the SmtpClient as
    I was not able to set the server/port set without error...but..

    I did find a great solution: (http://powershell.com/cs/media/p/306.aspx)

    $ol = New-Object -comObject Outlook.Application
    $mail = $ol.CreateItem(0)
    $Mail.Recipients.Add("mmccormick@xxxxxx")
    $Mail.Subject = "PS1 Script TestMail"
    $Mail.Body = "
    Test Mail
    "
    $Mail.Send()

    Thanks all !

    "Shay Levy [MVP]" wrote:

    > Hi mmccormick,
    >
    >
    > You can use the SmtpClient(server, port) overload and set the server/port:
    >
    > $smtp = new-object Net.Mail.SmtpClient(”localhost”,<portNumber>)
    >
    > or set it later:
    >
    > $smtp.port = <portNumber>
    >
    >
    > ---
    > Shay Levy
    > Windows PowerShell MVP
    > http://blogs.microsoft.co.il/blogs/ScriptFanatic
    > PowerShell Toolbar: http://tinyurl.com/PSToolbar
    >
    >
    >
    > m> Thanks Karl. What if the localhost is SMTP but is not 25?
    > m>
    > m> "Karl Mitschke" wrote:
    > m>

    > >> Hello mmccormick,
    > >>
    > >>> Hi, Can anyone tell me why this won't work for me?
    > >>>
    > >>> $smtp = new-object Net.Mail.SmtpClient(”localhost”)
    > >>> $smtp.Send(”myemail@xxxxxx”, “myemail@xxxxxx”, “test subjext”,
    > >>> “test body here”)
    > >>>
    > >>> Maybe I need a snap-in or something? Thank you!
    > >>>
    > >> Is your localhost an smtp server?
    > >>
    > >> from a command prompt, try this:
    > >>
    > >> telnet localhost 25
    > >>
    > >> If that works, you can try creating and sending an email from the
    > >> ppompt:
    > >>
    > >> helo
    > >> mail from: myemail@xxxxxx
    > >> rcpt to: myemail@xxxxxx
    > >> data
    > >> test body here
    > >> ..(enter a dot/period to end the data)
    > >> quit
    >
    >
    >

      My System SpecsSystem Spec

  7. #7


    mmccormick Guest

    Re: sending an email

    I have one more question...instead of using $Mail.Send() do you know of a way
    to have the email open for editing before I hit 'send' ? Thanks again!

    "mmccormick" wrote:

    > This isn't working for me so I just don't know enough about the SmtpClient as
    > I was not able to set the server/port set without error...but..
    >
    > I did find a great solution: (http://powershell.com/cs/media/p/306.aspx)
    >
    > $ol = New-Object -comObject Outlook.Application
    > $mail = $ol.CreateItem(0)
    > $Mail.Recipients.Add("mmccormick@xxxxxx")
    > $Mail.Subject = "PS1 Script TestMail"
    > $Mail.Body = "
    > Test Mail
    > "
    > $Mail.Send()
    >
    > Thanks all !
    >
    > "Shay Levy [MVP]" wrote:
    >

    > > Hi mmccormick,
    > >
    > >
    > > You can use the SmtpClient(server, port) overload and set the server/port:
    > >
    > > $smtp = new-object Net.Mail.SmtpClient(”localhost”,<portNumber>)
    > >
    > > or set it later:
    > >
    > > $smtp.port = <portNumber>
    > >
    > >
    > > ---
    > > Shay Levy
    > > Windows PowerShell MVP
    > > http://blogs.microsoft.co.il/blogs/ScriptFanatic
    > > PowerShell Toolbar: http://tinyurl.com/PSToolbar
    > >
    > >
    > >
    > > m> Thanks Karl. What if the localhost is SMTP but is not 25?
    > > m>
    > > m> "Karl Mitschke" wrote:
    > > m>

    > > >> Hello mmccormick,
    > > >>
    > > >>> Hi, Can anyone tell me why this won't work for me?
    > > >>>
    > > >>> $smtp = new-object Net.Mail.SmtpClient(”localhost”)
    > > >>> $smtp.Send(”myemail@xxxxxx”, “myemail@xxxxxx”, “test subjext”,
    > > >>> “test body here”)
    > > >>>
    > > >>> Maybe I need a snap-in or something? Thank you!
    > > >>>
    > > >> Is your localhost an smtp server?
    > > >>
    > > >> from a command prompt, try this:
    > > >>
    > > >> telnet localhost 25
    > > >>
    > > >> If that works, you can try creating and sending an email from the
    > > >> ppompt:
    > > >>
    > > >> helo
    > > >> mail from: myemail@xxxxxx
    > > >> rcpt to: myemail@xxxxxx
    > > >> data
    > > >> test body here
    > > >> ..(enter a dot/period to end the data)
    > > >> quit
    > >
    > >
    > >

      My System SpecsSystem Spec

  8. #8


    Shay Levy [MVP] Guest

    Re: sending an email

    Hello mmccormick,


    You mean open for editing in Outlook? What do you want to edit?



    ---
    Shay Levy
    Windows PowerShell MVP
    http://blogs.microsoft.co.il/blogs/ScriptFanatic
    PowerShell Toolbar: http://tinyurl.com/PSToolbar


    m> I have one more question...instead of using $Mail.Send() do you know
    m> of a way to have the email open for editing before I hit 'send' ?
    m> Thanks again!
    m>
    m> "mmccormick" wrote:
    m>

    >> This isn't working for me so I just don't know enough about the
    >> SmtpClient as I was not able to set the server/port set without
    >> error...but..
    >>
    >> I did find a great solution:
    >> (http://powershell.com/cs/media/p/306.aspx)
    >>
    >> $ol = New-Object -comObject Outlook.Application $mail =
    >> $ol.CreateItem(0) $Mail.Recipients.Add("mmccormick@xxxxxx")
    >> $Mail.Subject = "PS1 Script TestMail" $Mail.Body = " Test Mail "
    >> $Mail.Send()
    >>
    >> Thanks all !
    >>
    >> "Shay Levy [MVP]" wrote:
    >>

    >>> Hi mmccormick,
    >>>
    >>> You can use the SmtpClient(server, port) overload and set the
    >>> server/port:
    >>>
    >>> $smtp = new-object Net.Mail.SmtpClient(localhost,<portNumber>)
    >>>
    >>> or set it later:
    >>>
    >>> $smtp.port = <portNumber>
    >>>
    >>> ---
    >>> Shay Levy
    >>> Windows PowerShell MVP
    >>> http://blogs.microsoft.co.il/blogs/ScriptFanatic
    >>> PowerShell Toolbar: http://tinyurl.com/PSToolbar
    >>> m> Thanks Karl. What if the localhost is SMTP but is not 25?
    >>> m>
    >>> m> "Karl Mitschke" wrote:
    >>> m>
    >>>>> Hello mmccormick,
    >>>>>
    >>>>>> Hi, Can anyone tell me why this won't work for me?
    >>>>>>
    >>>>>> $smtp = new-object Net.Mail.SmtpClient(localhost)
    >>>>>> $smtp.Send(myemail@xxxxxx, myemail@xxxxxx, test
    >>>>>> subjext, test body here)
    >>>>>>
    >>>>>> Maybe I need a snap-in or something? Thank you!
    >>>>>>
    >>>>> Is your localhost an smtp server?
    >>>>>
    >>>>> from a command prompt, try this:
    >>>>>
    >>>>> telnet localhost 25
    >>>>>
    >>>>> If that works, you can try creating and sending an email from the
    >>>>> ppompt:
    >>>>>
    >>>>> helo
    >>>>> mail from: myemail@xxxxxx
    >>>>> rcpt to: myemail@xxxxxx
    >>>>> data
    >>>>> test body here
    >>>>> ..(enter a dot/period to end the data)
    >>>>> quit


      My System SpecsSystem Spec

  9. #9


    mmccormick Guest

    Re: sending an email

    Instead of using $Mail.Send() to send the email at the end of the script,
    I'd like to have it open on my desktop so that I can view/edit before I
    actually send it. Is there a method for that, something like $Mail.Open() ?
    Thanks!

    "Shay Levy [MVP]" wrote:

    > Hello mmccormick,
    >
    >
    > You mean open for editing in Outlook? What do you want to edit?
    >
    >
    >
    > ---
    > Shay Levy
    > Windows PowerShell MVP
    > http://blogs.microsoft.co.il/blogs/ScriptFanatic
    > PowerShell Toolbar: http://tinyurl.com/PSToolbar
    >
    >
    > m> I have one more question...instead of using $Mail.Send() do you know
    > m> of a way to have the email open for editing before I hit 'send' ?
    > m> Thanks again!
    > m>
    > m> "mmccormick" wrote:
    > m>

    > >> This isn't working for me so I just don't know enough about the
    > >> SmtpClient as I was not able to set the server/port set without
    > >> error...but..
    > >>
    > >> I did find a great solution:
    > >> (http://powershell.com/cs/media/p/306.aspx)
    > >>
    > >> $ol = New-Object -comObject Outlook.Application $mail =
    > >> $ol.CreateItem(0) $Mail.Recipients.Add("mmccormick@xxxxxx")
    > >> $Mail.Subject = "PS1 Script TestMail" $Mail.Body = " Test Mail "
    > >> $Mail.Send()
    > >>
    > >> Thanks all !
    > >>
    > >> "Shay Levy [MVP]" wrote:
    > >>
    > >>> Hi mmccormick,
    > >>>
    > >>> You can use the SmtpClient(server, port) overload and set the
    > >>> server/port:
    > >>>
    > >>> $smtp = new-object Net.Mail.SmtpClient(”localhost”,<portNumber>)
    > >>>
    > >>> or set it later:
    > >>>
    > >>> $smtp.port = <portNumber>
    > >>>
    > >>> ---
    > >>> Shay Levy
    > >>> Windows PowerShell MVP
    > >>> http://blogs.microsoft.co.il/blogs/ScriptFanatic
    > >>> PowerShell Toolbar: http://tinyurl.com/PSToolbar
    > >>> m> Thanks Karl. What if the localhost is SMTP but is not 25?
    > >>> m>
    > >>> m> "Karl Mitschke" wrote:
    > >>> m>
    > >>>>> Hello mmccormick,
    > >>>>>
    > >>>>>> Hi, Can anyone tell me why this won't work for me?
    > >>>>>>
    > >>>>>> $smtp = new-object Net.Mail.SmtpClient(”localhost”)
    > >>>>>> $smtp.Send(”myemail@xxxxxx”, “myemail@xxxxxx”, “test
    > >>>>>> subjext”, “test body here”)
    > >>>>>>
    > >>>>>> Maybe I need a snap-in or something? Thank you!
    > >>>>>>
    > >>>>> Is your localhost an smtp server?
    > >>>>>
    > >>>>> from a command prompt, try this:
    > >>>>>
    > >>>>> telnet localhost 25
    > >>>>>
    > >>>>> If that works, you can try creating and sending an email from the
    > >>>>> ppompt:
    > >>>>>
    > >>>>> helo
    > >>>>> mail from: myemail@xxxxxx
    > >>>>> rcpt to: myemail@xxxxxx
    > >>>>> data
    > >>>>> test body here
    > >>>>> ..(enter a dot/period to end the data)
    > >>>>> quit
    >
    >
    >

      My System SpecsSystem Spec

  10. #10


    RickB Guest

    Re: sending an email

    I guess you didn't understand Shay's question.

    SMTP simply facilitates transmission of email messages.

    Outlook is an application that manages messages, addresses, address
    lists and provides facilities for creating and editing messages. It
    then uses the same SMTP calls that you could use to send the message.

    The point is Outlook provides the editing services.

    If you want to edit an email message you need to have a program
    designed to edit email messages.
    Given you've got one, someone can probably help you pass your pre-
    built message into it for further editing...
    But you need to state which editor(s) are available.

    mmccormick wrote:

    > Instead of using $Mail.Send() to send the email at the end of the script,
    > I'd like to have it open on my desktop so that I can view/edit before I
    > actually send it. Is there a method for that, something like $Mail.Open()?
    > Thanks!
    >
    > "Shay Levy [MVP]" wrote:
    >

    > > Hello mmccormick,
    > >
    > >
    > > You mean open for editing in Outlook? What do you want to edit?
    > >
    > >
    > >
    > > ---
    > > Shay Levy
    > > Windows PowerShell MVP
    > > http://blogs.microsoft.co.il/blogs/ScriptFanatic
    > > PowerShell Toolbar: http://tinyurl.com/PSToolbar
    > >
    > >
    > > m> I have one more question...instead of using $Mail.Send() do you know
    > > m> of a way to have the email open for editing before I hit 'send' ?
    > > m> Thanks again!
    > > m>
    > > m> "mmccormick" wrote:
    > > m>

    > > >> This isn't working for me so I just don't know enough about the
    > > >> SmtpClient as I was not able to set the server/port set without
    > > >> error...but..
    > > >>
    > > >> I did find a great solution:
    > > >> (http://powershell.com/cs/media/p/306.aspx)
    > > >>
    > > >> $ol = New-Object -comObject Outlook.Application $mail =
    > > >> $ol.CreateItem(0) $Mail.Recipients.Add("mmccormick@xxxxxx")
    > > >> $Mail.Subject = "PS1 Script TestMail" $Mail.Body = " Test Mail"
    > > >> $Mail.Send()
    > > >>
    > > >> Thanks all !
    > > >>
    > > >> "Shay Levy [MVP]" wrote:
    > > >>
    > > >>> Hi mmccormick,
    > > >>>
    > > >>> You can use the SmtpClient(server, port) overload and set the
    > > >>> server/port:
    > > >>>
    > > >>> $smtp = new-object Net.Mail.SmtpClient(localhost,<portNumber>)
    > > >>>
    > > >>> or set it later:
    > > >>>
    > > >>> $smtp.port = <portNumber>
    > > >>>
    > > >>> ---
    > > >>> Shay Levy
    > > >>> Windows PowerShell MVP
    > > >>> http://blogs.microsoft.co.il/blogs/ScriptFanatic
    > > >>> PowerShell Toolbar: http://tinyurl.com/PSToolbar
    > > >>> m> Thanks Karl. What if the localhost is SMTP but is not 25?
    > > >>> m>
    > > >>> m> "Karl Mitschke" wrote:
    > > >>> m>
    > > >>>>> Hello mmccormick,
    > > >>>>>
    > > >>>>>> Hi, Can anyone tell me why this won't work for me?
    > > >>>>>>
    > > >>>>>> $smtp = new-object Net.Mail.SmtpClient(localhost)
    > > >>>>>> $smtp.Send(myemail@xxxxxx, myemail@xxxxxx, test
    > > >>>>>> subjext, test body here)
    > > >>>>>>
    > > >>>>>> Maybe I need a snap-in or something? Thank you!
    > > >>>>>>
    > > >>>>> Is your localhost an smtp server?
    > > >>>>>
    > > >>>>> from a command prompt, try this:
    > > >>>>>
    > > >>>>> telnet localhost 25
    > > >>>>>
    > > >>>>> If that works, you can try creating and sending an email from the
    > > >>>>> ppompt:
    > > >>>>>
    > > >>>>> helo
    > > >>>>> mail from: myemail@xxxxxx
    > > >>>>> rcpt to: myemail@xxxxxx
    > > >>>>> data
    > > >>>>> test body here
    > > >>>>> ..(enter a dot/period to end the data)
    > > >>>>> quit
    > >
    > >
    > >

      My System SpecsSystem Spec

Page 1 of 2 12 LastLast
sending an email problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
email not sending kellgirl Vista mail 2 17 Mar 2010
Daily Limit on Sending/Recieving email for live.com email address? Candice Live Mail 4 18 Aug 2008
Windows Live Mail-No message in body of email when sending email m frisket Live Mail 10 03 Apr 2008
email not sending outgoing messages with normal email account scopes Vista mail 2 18 Mar 2008
my email senders receive a warning after sending me email alan111074 Vista mail 1 04 Aug 2007