• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1073
  • Last Modified:

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"
0
kake26
Asked:
kake26
  • 4
  • 3
1 Solution
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now