Retain formating from outlook email into word document?

As you can obviously tell from the script, I don't do this for a living.

The script takes the contents of an existing email in outlook, removes some 
stuff from the header and then writes it to a new MS Word document.  It is 
working.

The next step is to get it to preserve the HTML formatting of the original 
email message.  

I tried Changing "$messagebody = $m.body" and 
"$selection.TypeText($wordcontent[1])"  to "$messagebody = $m.htmlbody" and 
$selection.TypeText($messagebody)"  but it didn't work.

So I'm pretty much out of ideas about how to retain the html formatting when 
I import into word.



#OPEN OUTLOOK
$ol = new-object -comobject "outlook.application"

#GET THE RIGHT FOLDER
#folder name is hard coded for now and depends on outlook rule

$k = $ol.Session.Folders.Item(1).folders
foreach ($f in $k) {if ($f.name -eq "temp") {$b = $f} }

#START LOOP

foreach ($m in $b.Items) {
$messagebody = $m.body


#PARSE THE BODY - splits @ subject
# so saveas uses original subject as filename
$wordcontent =  $messagebody -split "Subject: "


#OPEN WORD and MAKE DOCUMENT and MAKE SELECTION
$word = new-object -comobject "word.application"
$document = $word.documents.add()
$selection = $word.selection

#make the document visible for testing
$word.visible = 1

#ADD CONTENT  
$selection.TypeText($wordcontent[1])

#Save document

$document.SaveAs()
$document.close()
$word.quit()

}    #END LOOP
0
Utf
6/30/2010 10:09:10 PM
windows.powershell 690 articles. 0 followers. Follow

0 Replies
1671 Views

Similar Articles

[PageSpeed] 57

Reply:

Similar Artilces:

Email Addresses #2
When I type in the first few letters of an email address a drop down apears with four or five email address. They are all for the same person, but only 1 is correct. How do I get rid of the incorrect email address? I have gone to the custom dicsonary in outlook and erased the wrong one there, but not all of them are there and even the ones I erased still show up. Any help would be helpful. Thanks When you start to type the address and the wrong address appears on the list, use your arrow keys to highlight that wrong address, then press [DELETE]. -- Aloha, -Ben- Ben M. Schorr, OneN...

Conditionally format another cell?
Is there a way to change the background color of a cell based on the contents of a different cell? thanks!!! Just use a formula that refers to the other cell. If I want X99 to change depending on what's in A1. I select X99 and then format|conditional formatting Formula is: =$A$1="anythingyouwant" Robin wrote: > > Is there a way to change the background color of a cell based on the > contents of a different cell? > > thanks!!! -- Dave Peterson ...

Time Format.
I have a column with numbers that represent seconds, for example 109. How can I change this number (109) to this format, 0:01:49 Use =TIME(0,INT(I1/60),MOD(I1,60)) and format it as h:mm:ss -- HTH Bob "GEM" <GEM@discussions.microsoft.com> wrote in message news:072EE4E4-9BE0-4835-B246-79D1F4DFE977@microsoft.com... >I have a column with numbers that represent seconds, for example 109. > > How can I change this number (109) to this format, 0:01:49 =A1/(24*60*60) and format as [h]:mm:ss -- David Biddulph "GEM" <GEM@dis...

Can't get 24 hour format to change to 12 hour in calendar
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Email Client: Exchange I have tried several times to change the International format setting to have a 12 hour am/pm set up in Entourage but the format still stays 24 hour in the Calendar display itself. Although the actual entries are in 12 hour format and Entourage uses the 12 hour format for everything else except how it shows the actual calendars. <br> Is there something else I need to do to have this display correctly in the calendars? <br> I'm using 2008 Web Services Edition. Love this produ...

convert from .xls format to .csv format
Hi, Can anyone help me to convert .xls to .csv without changing the content. I want the leading zeros to remain in the csv. Thanks in advance M.Ravindran -- m_ravindran ------------------------------------------------------------------------ m_ravindran's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=28668 View this thread: http://www.excelforum.com/showthread.php?threadid=483430 Hi take a look at the Text Write facility at http://www.tushar-mehta.com/excel/software/text_write_program/index.html Regards Roger Govier m_ravindran wrote: > Hi, >...

outlook 2003 and pocket mirror
I cannot get outlook 2003 to work with pocket mirror, infact outlook won't work at all with pocket mirror installed. I have downloaded the latest updates for both programs and wondered if anyone has managed to get these two programs to work together? I had the same problem when I was adding programs to my new lap top (XP Pro, Office 2003 Pro). Never did get my old Palm to hook up. Only option I found that worked was to get a new Palm with a USB sync. Tung E $200 loaded and worked fine flach@tiscali.co.uk (Peter Flach) wrote in news:41a926e3.0401010708.2ff62aa5@posting.google.com: ...

YYYY format displaying wrong date
I admit I'm confused by this. I'm using Excel '97 (Yes, yes, I know. Upgrade. But this is a client's system over which I have no control.) The client supplied me with a spreadsheet containing a lot of data. I need to make the data consistent for it to be usable. There is a column containing only the year which is currently defined as Text. I want the data to be Date type with a "YYYY" format. I managed to do this somehow in another spreadsheet of similar data. In the spreadsheet I'm currently working on, when I change the column to Date type with "YYY...

International date formats
When performing an Edit, replace on the cell value 10.09.03 (a system genereated date vale of 10th Sep 03) replaceing the . with /, Excel (and in VBA when recorded as a macro) sometimes changes the cell value to 09/10/03 (9th October 03). This is driving me potty and have spent a vast amount of time on it trying to work out what Excel is doing!!!! My Regional settings are set fro the UK. Any ideas anyone? "Mike" <michael.may@npower.com> wrote in message news:2d44701c39483$97f77730$a601280a@phx.gbl... > When performing an Edit, replace on the cell value > 10.09.0...

duplicate email messages
Is anyone aware of any settings in Outlook Express V6 that cause messages received and sent to be duplicated? This newsgroup is for support of Outlook 97, 98, 2000 & 2002 from the Office family for Windows PCs. For Outlook Express (OE) support try posting in one of these newsgroups: microsoft.public.inetexplorer.ie4.outlookexpress for OE 4.x microsoft.public.windows.inetexplorer.ie5.outlookexpress for OE 5.x http://support.microsoft.com/newsgroups/default.aspx?ICP=GSS3&NewsGroup=microsoft.public.windows.inetexplorer.ie5.outlookexpress&SLCID=US&sd=GN&id=fh;en-us;newsgrou...

Upgrade Outlook XP to 2003
Hi After an upgrade MS-Office XP to 2003 Outlook in off-line mode doesn't work correctly. If I press F9 the dialog says conecting, replicating ...... OK. Everything looks good, but I dont't recieve any new mail from exchange (5.5) and nothing is send out :-( On-line or a cached mode works OK, but the outlooks are on ISDN line, so I need a off-line mode. Does anybody have any working idea :-) Martin Kucera ...

Area chart date format
I have an area chart that plots quarterly data. I want to show only years on the x-axis, so I changed the interval to 1 year and the number format to 'Custom yyyy'. However this is shortening my dates, so 2020 becomes 202. Bizarrely, 2021 and 2031 show up in full, but other dates are only shown by their first three digits. Any ideas? I suspect the space allotted for each label isn't quite long enough, so the last character is truncated. I know all digits are the same width, but sometimes, especially when the font size is small, "1" is narrower than the rest, whic...

Outlook 2003 02-04-10
I would like to display people names in my Contacts folder in the form 1stname 2ndname and have the display sorted in the order of 2ndname. I find the default display from Outlook more dyslexia-inducing than just about anything I've ever seen. There are no cues to scan it eith accross or up/down. Ideally I'd also like to have each entry displayed on one line with the contact's email address following their name. Is this possible? The Outlook help info gave a method for altering the display name order, but it did nothing to my contacts file when I applied the steps i...

Outlook migration problem #2
Have just abandoned a tower for an HP Pavilion 9000 laptop. Installed Outlook from my original software - Outlook 2002 SP3. Went to Tools / Options / Mail Setup / Data Files to point data source files as I've done for tower to tower migrations. But clicking Data Files gets "Not implemented" message. Same message from E-mail Accounts. From Send/Receive "OLE registration error." Any ideas where I go from here? ...

How do I show messages marked for deletion on Microsoft Outlook?
Microsoft Outlook 2003 When I delete messages in my Inbox (or any other folder) they are currently hidden. How do I change that so that the messages I click for deletion show up with a line through them? Conversely once I've done that if I want to change back to having messages marked for deletion hidden, how do I do that? THRP <THRP@discussions.microsoft.com> wrote: > Microsoft Outlook 2003 > When I delete messages in my Inbox (or any other folder) they are > currently hidden. How do I change that so that the messages I click > for deletion show up with a line thr...

Formatting Formulas
I have a series of formulas that creates English Language labels out of a variety of VLOOKUP's and the ever helpful & sign. Basically, I used the VLOOKUPS to get "Big", "Bag", "Delicious", and "Apples" in cells A1-D1, respectively. Then, in E1, I've got =A1&" "&B1&" of "&C1&" "&D1 so that it comes out Big Bag of Delicious Apples In E2 it says Small Bundle of Tart Grapes and E3 says Big Bundle of Tart Apples, etc. What I'd like to have, though, is some sort of formatting set u...

Protection Formatting
Hi, Is it possible to protect only the format of any particular cell. Like border, shading, font etc.etc. Thus even if any valus is entered/ pasted into this cell, the original formatting will remain unaltered? Brgds, Kedar "Kedar J" <kedaris@yahoo.com> wrote in message news:094701c34b9c$2ddc4ea0$a601280a@phx.gbl... > Hi, > > Is it possible to protect only the format of any > particular cell. Like border, shading, font etc.etc. Thus > even if any valus is entered/ pasted into this cell, the > original formatting will remain unaltered? > > Brgds, &g...

Format a single digit like "007"?
In the query result, I need to see (for example) a single digit number (say that "7") as "007". What is the function for this? I use FormatNumber function for other purposes. Can you help me please? try the following: format(7,"000") 007 format(77,"000") 077 format(777,"000") 777 "mezzanine1974" wrote: > In the query result, I need to see (for example) a single digit number > (say that "7") as "007". > What is the function for this? I use FormatNumber function for other > purposes. > Can you he...

Retainers
Does anyone know the process of receiving retainers and then applying them to the invoice. I need thenm to show up on the invoice. Any help is appreciated. Thank you, Brian In microsoft.public.money, bcarne wrote: >Does anyone know the process of receiving retainers and >then applying them to the invoice. I need thenm to show >up on the invoice. >Any help is appreciated. Not many Business users provide answers. ...

Outlook Security Tab Missing
Hi, On one of our users' Outlook 2003 on XP SP2 machines, there is no security tab for the Outlook folders. Other tabs are also missing, like about half of them. Can't find the solution on a google search. It is exchange 2003 SBS server and outlook using cached mode same as all the other workstations - but this one is missing a number of tabs when I right click on any folder in Outlook. Please help. thanks Paddy Many, Many, moons ago this problem was caused by a corrupt or missing file. It seems to me that IE 4 or 5 was involved too. I ran a search on this and found only the...

Pivot Table formatting #6
When I format my pivot tables I have "preserve formatting" checked under "PivotTable Options", and "Autoformat Table" unchecked. Even so, I either lose portions of my formatting, or different formatting is applied when I refresh. Does anyone know what I am doing incorrectly or have any other suggestions? Thanks, Phil Other things to try -- if they don't work, you could record a macro as you refresh and reformat the pivot table. Then, run that when you want to update. --Instead of selecting the cells to format the numbers, right-click the field but...

is ther any microsoft support for outlook any where?
...

Format Cell #5
I have a spreadsheet that is used by multiple users. I need to see if there is a way to separate floor numbers and room numbers. Example: In column "D" there will be: 5012-2 6004 7012-3 6004-02 ICUD 3014a The floor number is the first number in the column. I need to see if this can be separated to 5th floor, 6th floor, ICU (which may also be listed as 3014, 3012 etc. or ICU). I need to have a formula to count the number that went to the 5th floor, 6th, etc. I thought that if there is a formula to enter to separate the floors instead of adding another column and having e...

Font and text size change when writing email
Hi, When I write an email in CRM 4 web client I'm getting some strange things happening with the txt. When I press enter to the next line the font and text size changes. So you know why this is happening? Thanks, Ben Unfortunately the WYSIWYG editor is not brilliantly clever and you can easily fool it, resulting in source like that below. As you see the second 'hello' has lost its style. <HTML><HEAD><LINK href="/_forms/controls/controls.css.aspx" rel=stylesheet></HEAD> <BODY contentEditable=true> <P><FONT face="Tahoma...

outlook 2003 archiving issue
Hi Guys, I have a client running office 2003, when trying to archive his mailbox, he gets this error: Error while archiving folder "(directory)" in store "Mailbox - (username)". Path does not exist. Make sure the path is correct. Can anyone shed any light onto this error message? What have you tried so far to troubleshoot this issue? -- Jocelyn Fiorello MVP - Outlook *** Messages sent to my e-mail address will NOT be answered -- please reply only to the newsgroup to preserve the message thread. *** In news:111101c47b51$3b1cff20$a401280a@phx.gbl, Dave wrote: &g...

Mailbox size out of porpotion to number of emails
Hello! My boss came to me asking why his mailbox is so large. I checked, and it is out of porportion to the number of messages he has. I'm asking our security person to run a virus check just as a precaution- the server is protected 24/7- and am looking for other ideas of what to check. Any ideas appreciated. Thanks! Natalie ...