Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Win32::OLE - copying and pasting outlook body and pasting to Word

by tallwithblueeyes (Novice)
on Sep 24, 2009 at 15:28 UTC ( [id://797231]=perlquestion: print w/replies, xml ) Need Help??

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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://797231]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 02:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found