perl cdo.message question

Alright folks here is the script I have and the error I keep getting. I've been googling for hours and searching news groups to no avail. I know someone out here has a clue, so please enlighten me.

use Win32::OLE;
use CGI;

$cgi = new CGI;
print $cgi->header();

$cdo = Win32::OLE->new('CDO.Message') or die "NOT SUPPORTED";
$cdoc = Win32::OLE->new('CDO.Configuration') or die "NOT SUPPORTED";

$cdoc->{'cdoSendUsingMethod'} = "2";
$cdoc->{'cdoSMTPServer'} = "mail-fwd";
$cdoc->{'cdoSMTPServerPort'} = "25";
$cdoc->{'cdoSMTPconnectiontimeout'} = "10";
$cdoc->Update();

print Win32::OLE-> LastError();
print "<br>";

#$cdo->{Configuration} = $cdoc;

$cdo->{From} = "rtfmc\@r-t-f-m.com";
$cdo->{To} = "kake26\@gmail.com";
$cdo->{Subject} = "TESTING PERL CDO";
$cdo->{TextBody} = "TEST";

$cdo->Send();

print Win32::OLE-> LastError();

error is below

OLE exception from "CDO.Message.1": The "SendUsing" configuration value is invalid. Win32::OLE(0.1701) error 0x80040220 in METHOD/PROPERTYGET "Send"
kake26Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

clockwatcherCommented:
The following works for me:

use Win32::OLE;
use CGI;

$cgi = new CGI;
print $cgi->header();

$sch = "http://schemas.microsoft.com/cdo/configuration/";

$cdo = Win32::OLE->new('CDO.Message') or die "NOT SUPPORTED";
$cdoc = Win32::OLE->new('CDO.Configuration') or die "NOT SUPPORTED";

$cdoc->Fields->{"$sch/sendusing"} = 2;
$cdoc->Fields->{"$sch/smtpserver"} = "someserver.somewhere.com";
$cdoc->Fields->{"$sch/smtpserverport"} = 25;
$cdoc->Fields->{"$sch/smtpconnectiontimeout"} = 10;
$cdoc->Update();

print Win32::OLE-> LastError();
print "<br>";

$cdo->{Configuration} = $cdoc;
$cdo->{From} = "notme\@somewhere.com";
$cdo->{To} = "notyou\@somewhere.com";
$cdo->{Subject} = "TESTING PERL CDO";
$cdo->{TextBody} = "TEST";

$cdo->Send();

print Win32::OLE-> LastError();
0
kake26Author Commented:
Indeed this is one of the version I came up with myself last night yet it didn't work. I'm assuming it must be something related to that server. Its a win2k3 and IIS 6 with activeperl installed. Maybe the version of win32::OLE was old I'll compile it with my pdk and try it that way. If anyone else has something to add to this, do so now. I'm closing this out on friday evening.
0
clockwatcherCommented:
Did you try my script?  What error do you get with it?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

kake26Author Commented:
Yes, I certainly tried yours. I got the same error as posted before. Which makes me think they did something special somehow. I haven't the foggiest idea how or what, but I will attempt to find out. Howerver, I'll post the error anyhow.

OLE exception from "CDO.Message.1": The "SendUsing" configuration value is invalid. Win32::OLE(0.1701) error 0x80040220 in METHOD/PROPERTYGET "Send"

I also think my PDK won't help solve this. I suppose I could run VB code this was translated from via OLE directly as it was. I'm just trying to send mail without having to have to use a acctual e-mail account. Under *nix I can do it with my eyes closed but for windows CDO seemed to be the natural way to go. For grins I'm including a link to the original VBS source here and see if this can hopefully help out.

http://www.verio.com/support/documents/view_article.cfm?doc_id=3894

Yes, hosting on a win2k3 with IIS 6 @verio.  Clockwatcher, maybe this helps some how.
0
clockwatcherCommented:
The scripts look like they ought to work.

But, if all you're after is sending some standard emails, you could go with a more perlish solution and use Net::SMTP (http://www.verio.com/support/documents/view_article.cfm?doc_id=3905)

    use Net::SMTP;

    $from = 'me@here.com';
    $to = 'you@there.com';
    $subject = "This is the subject";
    $body = "This is the body";

    $smtp = Net::SMTP->new('mail-fwd');

    $smtp->mail($from);
    $smtp->to($to);

    $smtp->data();
    $smtp->datasend("To: $to\n");
    $smtp->datasend("Subject: $subject\n");
    $smtp->from("From: $from\n");
    $smtp->datasend("\n");
    $smtp->datasend("$body\n");
    $smtp->dataend();

    $smtp->quit;
0
clockwatcherCommented:
Sorry wasn't paying a lot of attention (people yacking in my ear):

   use Net::SMTP;

    $from = 'me@here.com';
    $to = 'you@there.com';
    $subject = "This is the subject";
    $body = "This is the body";

    $smtp = Net::SMTP->new('mail-fwd');

    $smtp->mail($from);
    $smtp->to($to);

    $smtp->data();
    $smtp->datasend("To: $to\n");
    $smtp->datasend("Subject: $subject\n");
    $smtp->datasend("From: $from\n");
    $smtp->datasend("\n");
    $smtp->datasend("$body\n");
    $smtp->dataend();

    $smtp->quit;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kake26Author Commented:
Thank you for your help. I had CDO working earlier today and then overwrote it, oops. Anyhow Net::SMTP works and does so every single time.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.