PDA

View Full Version : why is all formating lost



saban
04-06-2006, 08:30 AM
when I put activedocument.content into body of e-mail all formating is lost (like fonts are no longer blue and so on..)

Why
any ideas

Thnx

fumei
04-06-2006, 10:12 PM
Is your email body as HTML, or plaintext?

fumei
04-06-2006, 10:13 PM
Oh...and how are you getting it in there? As in:* * * * * yadda yadda Outlook code * * * *
MailItem.Body = ActiveDocument.Content

saban
04-11-2006, 12:45 AM
Yes
Is that what I am doing wrong?

saban
04-19-2006, 01:55 AM
Oh and it is plain text

TonyJollans
04-19-2006, 03:05 AM
Oh and it is plain text
... and plain text is what you get. Spot the connection?

saban
04-19-2006, 04:40 AM
I eman plain text is in email body not in word document
In word document I have bolded and coloured words but when this content is put into email I get just plain text

Any ideas

TonyJollans
04-19-2006, 05:57 AM
... when this content is put into email I get just plain text There are two things which could happen when you bring together formatted text and a plain text container:
1) The formatted text could lose its formatting to fit in with the constraint of its new container
2) The container could be changed.

Your e-mail client (you don't say which one) decided on the former, as most do. I doubt there's an option to change the behaviour; you must do it yourself before pasting.

saban
04-19-2006, 07:28 AM
I am using outlook 2003

fumei
04-19-2006, 11:09 PM
What Tony is saying is that your email is plain text....so anything put into it (the container) becomes plain text. It IS plain text. It ignores anything else.

Your format is in Word. You may copy it, but if the receiver of that copy does not care (as it is set up as plain text) then when it gets that copy it simply says...I don't know what to do with this other stuff...oh well.

TonyJollans
04-19-2006, 11:39 PM
Thank you Gerry.

saban
04-20-2006, 12:42 AM
Aha so that is the problem
Any ideas how can this be avoided?
(But why when I copy and paste table or formatted text from word document into e-mail body the formatting stays the same it does not turn into plain text)

fumei
04-20-2006, 01:32 AM
(But why when I copy and paste table or formatted text from word document into e-mail body the formatting stays the same it does not turn into plain text)You are confusing me! Your post states that you are copying text into the email and it is NOT formatted. Which is it?

And Tony? You're welcome.

saban
04-20-2006, 02:49 AM
I am putting text from word document into e-mail's body with statement
.Body = ActiveDocument.Content but if I do it manually like
select text in document then ctrl+c and then open new e-amil and press
ctrl+v so the text is pasted into body of email the formatting stays intact, but if I use .Body = ActiveDocument.Content in code then all formatting is lost

TonyJollans
04-20-2006, 04:40 AM
If I manually paste formatted text into a plain text e-mail in Outlook 2003, I get plain text. Are you quite sure your new e-mail is plain text?

saban
04-20-2006, 05:30 AM
Sorry actually it is HTML text I just realized (under properties)
and here is the source of e-mail
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7036.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Zahtevek za poravnavo od : lpoljak</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">_____________________________________________________________________</FONT>
<BR><FONT SIZE=2 FACE="Arial">za naslednji dokument:</FONT>
<BR><FONT SIZE=2 FACE="Arial">Tip in Fdr</FONT><SPAN LANG="sl"> <FONT SIZE=2 FACE="Arial CE">Št. : ADGDG&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Rok: GDFG &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Postopek: DFGD</FONT></SPAN>
<BR><SPAN LANG="sl"><FONT SIZE=2 FACE="Arial CE">Spomin: GDFG (GF)</FONT></SPAN>
</P>
<P><SPAN LANG="sl"><FONT SIZE=2 FACE="Arial CE">Dokumenti ki jih želim alinirane :</FONT></SPAN>
</P>
<P><SPAN LANG="sl"><FONT SIZE=2 FACE="Arial CE">GFGFGF</FONT></SPAN>
</P>
<BR>
</BODY>
</HTML>

TonyJollans
04-20-2006, 05:42 AM
Try using .HTMLBody = whatever instead of .Body = whatever

saban
04-21-2006, 12:50 AM
sorry it ididnt work i tried
.HTMLBody = ActiveDocument.Content

and it gives me some strange positioning of words( without tabs and paragraphs between some of them) But colors are still lost

Thnx

TonyJollans
04-21-2006, 01:27 AM
Sorry - but I haven't got time to check all this out; I don't know Outlook very well and I'm having to guess. If you can't extract the HTML directly from Word, why not use the clipboard to do the same in code as you do manually - copy from Word and Paste into the MailItem? I don't know how to do it; if nobody else comes forward I'll try to have a look over the weekend.

TonyJollans
04-23-2006, 07:06 AM
Hi saban,

This is rather more complicated than you might expect - unless I have missed something obvious again.

From your posts so far, I assume you are running in Word and already have a pointer to a new MailItem

' Dim objMailItem As Object ' Outlook.MailItem ' I assume you already have this

Dim objDocument As Object ' Word.Document
Dim objTempDoc As Object ' Word.Document

Dim fso As Object ' Scripting.FileSystemObject
Dim objTextStream As Object ' Scripting.TextStream

Dim strTempFileName As String
Dim iTemp As Integer

' Get an unused name for a temporary file
Set fso = CreateObject("Scripting.FileSystemObject")

For iTemp = 0 To 9999
strTempFileName = Environ("TEMP") & "\Temp" & Format(iTemp, "0000") & ".htm"
If Not fso.FileExists(strTempFileName) Then Exit For
Next

' Copy your ActiveDocument to a temporary document
Set objDocument = ActiveDocument
Set objTempDoc = Documents.Add

objDocument.Content.Copy
objTempDoc.Content.Paste

' .. and save it as HTML to the temporary filename determined above
With objTempDoc
.SaveAs strTempFileName, 8 ' wdFormatHTML
.Close
End With

' Tidy up
Set objDocument = Nothing
Set objTempDoc = Nothing

' Read the temporary file as (HTML) text into the mailitem
Set objTextStream = fso.GetFile(strTempFileName).OpenAsTextStream(1, -2)
objMailItem.HTMLBody = objTextStream.ReadAll

' Close the temporary file, tidy up and delete it
objTextStream.Close

Set objTextStream = Nothing
Set fso = Nothing

Kill strTempFileName

saban
04-24-2006, 06:33 AM
Thnx I will try this
I realy appreciate this