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

n00b question here. I am an MS-Office 2007 user, and am using Win32::OLE. I have an outlook email in HTML format as specified here:

#start Outlook and make it visible my $Outlook = Win32::OLE->GetActiveObject ('Outlook.Application') || Win32::OLE->new('Outlook.Application'); $Outlook->{'Visible'} = 1; my $message = $Outlook->CreateItem(olMailItem); $message->{BodyFormat} = 'olFormatHTML'; #needed for rich format #use a hash to populate address and subject fields $message->{HTMLBody} = $emailBody; my $clip = Win32::Clipboard($message->{HTMLBody});

If I manually copy and paste my email body from Outlook to Word, it copies fine, resulting in RTF in Word. Programatically though (see code snippet above), it seems to be copying straight HTML code to the clipboard. Then when pasted to Word, it comes out as HTML code, not the RTF I desire. How can i programatically copy and paste from the Outlook email body to Word so that it ends up as rich text?

Replies are listed 'Best First'.
Re: Win32::OLE - copying and pasting outlook body and pasting to Word
by Anonymous Monk on Sep 24, 2009 at 16:03 UTC
    d. Programatically though, it seems to be copying straight HTML code to the clipboard

    Please show your code, put it in <code></code> tags

      n00b question here. I am an MS-Office 2007 user, and am using Win32::OLE. I have an outlook email in HTML format as specified here:

      #start Outlook and make it visible my $Outlook = Win32::OLE->GetActiveObject ('Outlook.Application') || Win32::OLE->new('Outlook.Application'); $Outlook->{'Visible'} = 1; my $message = $Outlook->CreateItem(olMailItem); $message->{BodyFormat} = 'olFormatHTML'; #needed for rich format #use a hash to populate address and subject fields $message->{HTMLBody} = $emailBody; my $clip = Win32::Clipboard($message->{HTMLBody});

      If I manually copy and paste my email body from Outlook to Word, it copies fine, resulting in RTF in Word. Programatically though (see code snippet above), it seems to be copying straight HTML code to the clipboard. Then when pasted to Word, it comes out as HTML code, not the RTF I desire. How can i programatically copy and paste from the Outlook email body to Word so that it ends up as rich text?