in reply to Re: Re: Outlook MailItem Body Question
in thread Outlook MailItem Body Question

If Body is a subroutine, then the syntax for setting the value back would (probably) be

$items->Item($itemIndex)->Body( $body );

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!

Replies are listed 'Best First'.
Re: Re: Re: Re: Outlook MailItem Body Question
by Anonymous Monk on Jan 06, 2004 at 19:28 UTC
    Yeah, that's not it either... Body is an attribute, not a method, unfortunately.

      Did you actually try it?

      I realise that Body may be described as an attribute in the OLE documentation for Outlook, but the error message certainly imples that it ends up being implemented as a method within Win32::OLE.

      The error message is pretty indicative.

      { my $s = 'the quick brown fox'; sub Body{ ($s) = @_ if @_; $s } } print Body(); the quick brown fox Body = 'fred'; Can't modify non-lvalue subroutine call in scalar assignment at (eval +3) line 1, at EOF Body( 'fred' ); print Body(); fred

      If you did try it, what error message did you get from the attempt?


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      Hooray!

        Hmm, it seems if you try it as Body($mybody) instead of {'Body'} = $mybody you get an error "Invalid number of parameters" from Win32::OLE. For what it's worth, http://perlmonks.thepen.com/185757.html seems to think the {'Body'} method is correct.
Re4: : Outlook MailItem Body Question
by maa (Pilgrim) on Jan 07, 2004 at 09:30 UTC

    Straight from the VBA Outlook documentation:

    Body (Property).
    Returns or sets the clear-text body of the mail message or post. Read/write String.

      I understand that access to the body is implemented as a rw string in VBA.

      But the error message issued by perl when the OP attempted to assign to it via Win32::OLE:

      Can't modify non-lvalue subroutine call at ...,
      suggests fairly strongly that Win32::OLE implements access to the property using a subroutine -- Ie. an accessor/mutator method -- which does make a certain amount of sense.

      It may not be correct, but that is the implication of the error message.

        Agreed... but as I noted elsewhere, the implementation of automation for Outlook97 is Very Shoddy :-) ... I always though it had been added as an afterthought (as the rest of the Office 97 Object Model, except perhaps PowerPoint, was fairly good). Newer versions of Outlook have a better implementation.

        I used to hate havin to write Outlook Forms in VBScript and having to Chop/Change when I was controlling Excel/Access or whatever from them!