Insert word document/Bookmark into email body

G

Guest

i have a word document and created a bookmark which highlights the text i am
interested in.
i would like to insert the bookmark at the beginning of the email so that a
user's signature appears after the bookmark.
at the moment i i have been able to replace the body of the email with the
bookmark- but this removes the signature- this is to work on new emails- here
is the code:
mItem.Body= bmark
i have tried inserting the bookmark at the beginning of the body:

mItem.Body.Insert(0, bmark)

but this produces an object reference not set error

i am using outlook 2003, with HTMLBodyFormat and Word 2003.

Thanks
 
M

Michael Bauer [MVP - Outlook]

Am Fri, 15 Sep 2006 07:50:02 -0700 schrieb Paul:

Try this:

mItem.Body= bmark & vbCRLF & mItem.Body
 
G

Guest

nope-that doesnt work bmark "& operator isnt defined for types
Microsoft.Interop.Word.Bookmarks and String"

what I am really trying to do is instantiate an outlook template and to add
the user's default signature
 
M

Michael Bauer [MVP - Outlook]

Am Mon, 18 Sep 2006 03:05:02 -0700 schrieb Paul:

In a VBA group I assume VBA, not any .NET language, for which I can´t help
you.
 
S

Sue Mosher [MVP-Outlook]

I think Michael was assuming, by the way you wrote your mItem.Body= bmark statement, that bmark was a string variable holding the text from your bookmark. In that case, bmark & mItem.Body should be a legitimate string expression in VB.Net. If, however, it's a Word.Bookmark object, then you need to get the text first from Bookmark.Range.Text.

In any case, if the message is in HTML format, you would need to use HTMLBody, not Body, to preserve the formatting. But that's doing things the hard way. Since you have Word as the editor, you should use Word methods. See http://www.outlookcode.com/codedetail.aspx?id=615 for sample code.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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