http://qs321.pair.com?node_id=103852

TAC has asked for the wisdom of the Perl Monks concerning the following question:

Hello:

I am in search of Win32 Perl wisdom. I am trying to use CDONTS.NewMail and I am basically getting an empty reference back when I request the object using Win32::OLE. (When I dump the reference the only value is the "Version => 1.2".) I thought my box was hosed, but I just managed to use this dll in VB and ASP. Has anyone had any luck using this in an application?

Thanks,
TAC

Replies are listed 'Best First'.
Re: CDONTS.dll
by c-era (Curate) on Aug 10, 2001 at 18:23 UTC
    This code works for me, running perl 5.6.0 on an exchange server:
    use Win32::OLE; $cd = Win32::OLE->new("CDONTS.NewMail") || die $!; $cd->{From}="test\@test.com"; $cd->{To}="test\@test.com"; $cd->{Subject}="test"; $cd->{Body}="test"; $cd->Send; print Win32::OLE->LastError();
    if that doesn't work try this in VB and let me know if this works:
    Dim cp As Object Set cp = CreateObject("CDONTS.NewMail") With cp .To = "test@test.com" .From = "test@test.com" .Subject = "test" .Body = "test" .Send End With
    The above VB code forces VB to use the same OLE interface as Perl does.
      Bizarrely enough the perl snipet you sent me worked. I swear on a stack of Orielly books that I did exactly what you suggested last night and it didn't work. Oh well... However I spoke to our architect and he shunned CDONTS because you don't have control over the headers and footers. He suggested MIME::Lite as an alternative.

      Thanks for your help.
        There actually is a way to get control over the headers and footers, but it's not a pretty hack (plus I don't remember it off hand). Anyways, MIME::Lite is a better choice and is less system and software dependant.