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

I attempted that, but when it's written as you suggested, I get an error reading: "Can't modify non-lvalue subroutine call at ..." The method I came up with I found elsewhere on the web. Not sure if it's right, though. : )

Replies are listed 'Best First'.
Re: Re: Re: Outlook MailItem Body Question
by BrowserUk (Patriarch) on Jan 06, 2004 at 19:23 UTC

    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!

      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!

      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.