Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RE: CDO.Message What am I doing wrong?

62 views
Skip to first unread message

Peter

unread,
Mar 27, 2007, 9:13:56 PM3/27/07
to
PS H:\> &"C:\Documents and Settings\bla\Desktop\Email.ps1"


MemberType : Method
OverloadDefinitions : {void Send ()}
TypeNameOfValue : System.Management.Automation.PSMethod
Value : void Send ()
Name : Send
IsInstance : True

that's all it says... it doesn't actually send an email.


"RichS" wrote:

> What actually happens when you run the code? Do you get an error message?
> --
> Richard Siddaway
> Please note that all scripts are supplied "as is" and with no warranty
> Blog: http://richardsiddaway.spaces.live.com/
> PowerShell User Group: http://www.get-psuguk.org.uk
>
>
> "Peter" wrote:
>
> > Hi Everyone,
> >
> > What's wrong wtih my code? I ported this from my VBScript.
> >
> > $msg = new-Object -comobject "CDO.Message";
> >
> > $msg.From = "m...@email.com";
> > $msg.To = "m...@email.com";
> > $msg.Subject = "This is a test subject.";
> > $msg.TextBody = "This is a test body.";
> >
> > $msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ;
> > $msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.server.com";
> > $msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ;
> > $msg.Send;
> >
> > I'm a long-time VBScript coder since I am a Windows Administrator at a bank.
> > Since Powershell came out, I've been doing my darndest to learn it as well
> > as VBScript, but this last one has me pulling my hair out.
> >
> > By the way, I love the string-parsing capabilities of Powershell. AWESOME!

Brandon Shell

unread,
Mar 27, 2007, 10:39:27 PM3/27/07
to
try
$msg.Send()

"Peter" <Pe...@discussions.microsoft.com> wrote in message
news:5A0BA9FF-6B85-4711...@microsoft.com...

Brandon Shell

unread,
Mar 27, 2007, 10:44:56 PM3/27/07
to
Sorry... hit send prematurely. I wanted to explain why the ().

When you call a method like you have add the ().

p.s. You dont need ; at the end of every line if its a script. You only need
that if your gonna make multiple commands on one line. Here is example where
its needed
-- Code --
Write-Host "Hello" ; Write-Host "There"
-- Code --

You could also do this
-- Code --
Write-Host "Hello"
Write-Host "There"
-- Code --

"Peter" <Pe...@discussions.microsoft.com> wrote in message
news:5A0BA9FF-6B85-4711...@microsoft.com...

Peter

unread,
Mar 28, 2007, 4:34:02 PM3/28/07
to
Brandon,

Thanks for writing back. I tried it with '.Send()' and '.Send ()'. Neither
is working. Try running the code yourself at home, you'll see what I'm
talking about. Thanks.

Peter

0 new messages