Right... I've messed about in Perl and VBScrip this morning and my findings are this... I can do what you want in VB but not in Perl. Weird... (Outlook97, btw).

#!C:/ActivePerl/bin/perl.exe use strict; use warnings; use Win32::OLE; #Tset case - I know the app is running... my $Outlook = Win32::OLE->GetActiveObject("Outlook.Application"); my ($MAPI,$Inbox,$TestFolder,$Message,$bodytext,$newtext); $MAPI=$Outlook->GetNameSpace("MAPI"); $Inbox=$MAPI->GetDefaultFolder(6); $TestFolder=$Inbox->Folders("Perlmonks"); print "There are " . $TestFolder->{Items}->{Count} . " items in the in +box.\n\n"; for my $x (1) { $bodytext = $TestFolder->Items($x)->Body; print "Message Subject:\n" . $TestFolder->Items($x)->Subject . "\n +"; print "Body Text:\n$bodytext\n"; print "Replacing entire body with \"foo bar\"\n\n"; $TestFolder->Items($x)->{'Body'} = "foo bar"; #Doesn't work.. $TestFolder->Items($x)->LetProperty('Body',"foo bar") ; #Does't wo +rk.. $TestFolder->Items($x)->Save; #Doesn't make a difference! print "Body is now supposedly:\n\n" .$TestFolder->Items($x)->Body +. "\n"; #Hasn't updated! my $NewItem = $TestFolder->Items($x)->Copy; #Works fine }

And in VBScript...

'..snip... For Each M In objInbox.Items Text = Text & M.Subject & vbCr x=x+1 M.Body= "foo bar" 'Assignment msgbox M.Body 'Works perfectly M.Save Next '..snip...

I'm no expert but I couldn't get the SetProperty(property,@args,value) syntax to work in Win32::OLE... perhaps it's a bug? The VBScript/Automation of Outlook97 is pretty shoddy at the best of times. Outlook89 and above have VBA (rather than VBScript) automation, AFAIK, tho...


In reply to Re2: Outlook MailItem Body Question by maa
in thread Outlook MailItem Body Question by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.