New Email Message Body

W

webstuck

Hi,

I have a macro that opens a new email message. I then want to paste
whatever is copied into the email's body. I have the paste function
working, but it pastes into the email's to email field. I'm not sure
how to paste into the email's body section.

Thanks!
Ben Cunningham
 
M

Michael Bauer

Am 9 Dec 2005 13:45:57 -0800 schrieb webstuck:

Ben, at least you´d need to set the focus on the Body field what isn´t
possible with the OOM.

With Redemption (www.dimastr.com) you can set the cursor position and then
use your method to paste there.
 
D

Dmitry Streblechenko

Sure, open the clipboard, read the data, set it to the MaimItem.Body
property.
Does your code explicitly set the clipboard data (wiping out whatever is
already there)? If yes, why not explicitly set the MailItem.Body property
without using the clipboard?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
W

webstuck

Dmitry,

Is there a way to create a MailItem and set the MailItem.Body under
Windows XP SP2?

Thanks!
Ben
 
W

webstuck

Dmitry,

That worked great! I couldn't get it to work before because I forgot
to put the Item.Display line.

Thanks!
Ben
 
W

webstuck

Dmitry,

Now what I need the macro to do is copy the selected email text and
open a new email message with the body as the selected email text. I
was reading that there is no code for email selected text so I used the
commandbars code to go to file copy. Now how can I set the email body
to the copied text? Sorry, I am new to Outlook VBA.

Thanks!
Ben
 
W

webstuck

I already have the code to copy the text using:

myInspector.CommandBars("Edit").Controls("Copy").Execute

I just need to know how to get the copied text placed as a new email
message body.

Thanks!
Ben
 
M

Michael Bauer

Am 12 Dec 2005 20:33:57 -0800 schrieb webstuck:

Ben, your method copies the text into the Clipboard. You can access the
Clipboard by adding a reference to the "Microsoft Forms 2.0 Library" to your
project. Now you can create a DataObject which has a GetText function. A
sample is available in the VBA help file.
 
W

webstuck

I followed the sample in the VBA help file, but found that it doesn't
work for copied html code in email messages. Is there a method to get
copied text and html code from the clipboard?

Thanks!
Ben
 
M

Michael Bauer

Am 16 Dec 2005 01:11:40 -0800 schrieb webstuck:

Indeed, you´re right. I don´t know the format value for HTML. Maybe, as it´s
an user-defined format, the value changes.

You could register the HTML format for the clipboard yourself. But then
you´d have to get the selected text from the e-mail and also copy the text
yourself.

If you really insist on not to go the easy way (Redemption) then here´s
another, not very professional, approach (which I´d probably decline as your
customer):

Stick with your copy method, open a new Word Document, use the same method
to insert the copied text into the Document (i.e. automate the Insert button
click), save it as an HTML file, read the file´s content and apply that
string to your e-mail.
 

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