Format Email in body

M

matt

Hello,
I am using this code below to put the contents of the document into the body
of an Outlook email. Almost everything works perfect except for three Excel
Graphs that are links from Excel into the Word doc. When they show up in the
body of the email (before and after it is sent) they are blow up about 3x's
the size they are in the Word document. Why would this happen? I have try
..formattedtext etc.. and nothing seems to fix it.

Also there is a picture in the Word doc (.GIF) that is copy/pasted into the
doc, and when it is displayed in the message body it has the red "x" and it
says, "The image cannot be displayed. Your computer may not have enough
memory to open the image, or the image may have been corrupted. (etc....)".
If I delete it and copy/paste it directly into the message body it displays
correctly, just not when I use the code.
Any info would be much appreciated!!
_____________________________________________________
Sub SendDocumentInMail()
'Send document in body of email
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
'Outlook wasn't running? Start it from code.
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
'Set the recipient for the new email
.To = "(e-mail address removed)"
'Set the recipient for a copy
.CC = "(e-mail address removed)"
'Set the subject
.Subject = "Daily Report"
'The content of the document is used as the body for the email
'ActiveDocument.Range.FormattedText
'Selection.Copy
ActiveDocument.Range.Copy
.GetInspector.WordEditor.Range.Paste
End With

If bStarted Then
'If started Outlook from code, then close it
oOutlookApp.Quit
End If

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub
_______________________________________________________
 
A

aushknotes

Hi Matt,

Would you mind sharing how you get passed the WordEditor security in the
statement:

.GetInspector.WordEditor.Range.Paste

Thanks,
 
M

matt

I'm not sure what security you mean? But I was using .Selection.Copy , but
that only displayed as plain text, and no formatting. But as for your
question I didnt experience any problems when using that code. If you could
explain any further maybe I could help.
 
A

aushknotes

If you're using W2003, PF1 Help on the keyword 'WordEditor' and the microsoft
VBA help displays a help message saying that the WordEditor is diabled for
security reasons. I'm puzzled why you guys still can get thru it. Probably
you're running a different version. Also I reckon Graham Mayor had raised the
same problem under a thread named "How to get to email from Word". I tried
his latest codes supposed to be working, but... So I've raised a new thread
"Re:How to get to email from Word" describing the error I am current stuck
on. Please refer to that thread for details.

Cheers,
 
M

matt

Are you doing this in Word VBA?
If you are, you have to have a reference to Outlook. In the VBA editor go to
Tools/References then check Microsoft Outlook Object Library.
To make Word as your default editor in Outlook and see about security, check
out this link http://email.about.com/cs/outlooktips/qt/et041401.htm .
Also look at this post I had named "Macro to access Outlook 2007" dated
6/25/2008, I know it's version 2007 but maybe it will help! I do use Outlook
2007 and it uses Word as it's default and only editor. Maybe that is why I am
not getting any security problems.

Also if you want to give me your email address I can answer you back sooner.
Because of the security at my work I am unable to participate in forums while
at work. I can view and read but cannot reply or write new questions. So I
usually have to wait until I get home.
 
M

matt

Also, if you haven't already gotten past your problem you can email or reply
to this with the code you are using.
One other thig to look at: If you have created the reference to Outlook
Object Library , look on the "Standard Tool Bar" and click the button called
"Object browser" and search for "WordEditor". This will show you what class
this object is associated with.
 
A

aushknotes

Hi Matt,

I am sure I have made a reference to Outlook Library or I would have failed
in the Dim xxx as Outlook statement.

What you suggested in your last reply regarding checking the default editor
could be the main issue why WordEditor properties or methods were not there.
This could be the culprit. I will check it when I return to office tomorrow.
I am suspecting the default editor could be text editor. If so this will be
it because I have absolutely no chance to change the enterprise decision.
Will let you know ASAP.

Many thanks,
 
A

aushknotes

Many thanks, Matt. I'm just opposite to you. I can access this forum but not
personal emails at work. Anyway, there could be a hugh time difference
between us as I am in Sydney Australia.

Cheers,
 
A

aushknotes

Hi Matt,

You are absolutely correct. My outlook default is to use RichText but the
option 'use Word 2003 to edit email messages' is default to unchecked. So,
once I check this option, it codes work perfectly.

BTW, do you know how to check/uncheck the option 'use Word 2003 to edit
email messages' ?

Many thanks again,
 
G

Graham Mayor

In Outlook > Tools > Options > Mail Format > HTML format - uncheck the box
"Reduce the file size of the message by removing formatting information that
Is not necessary to display the e-mail message"

which should fix your graphics bloat problem


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

Try checking it, then OK, then uncheck and OK. If this doesn't fix it I
cannot think of any other issue that might affect it. Ask in an Outlook
forum.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top