writing info to an open email

smiler44

Registered User.
Local time
Today, 20:02
Joined
Jul 15, 2008
Messages
678
I have an open email that I would like to write data to.
How do I take control of the open email?

thank you
smiler44
 
hi smiler,

You would have to interact with the ActiveInspector property. I could never get this to work with a reply email but a fresh email is simple enough.
the following will give you "control" of the email. use myReadItem and play with it as you want.
Code:
Public Sub cbvf()
Dim myOlApp As Outlook.Application
Dim myReadItem As Object
Set myOlApp = CreateObject("Outlook.Application")
Set myReadItem = myOlApp.ActiveInspector.CurrentItem
myReadItem.Body = whatever
 
Isskint, thank you.
I am getting an error message:
run time error 91
object variable or with block variable not set
when this line is executed
Set myReadItem = myOlApp.ActiveInspector.CurrentItem

I am not replying to an email. I have opened a draft email and want to paste information into it

smiler44
 
That is strange. I have just run that code and it is fine (Outlook 2007 & Outlook 2003). I assume you have a reference to Outlook library set (must have otherwise it would have tripped over on the 1st Dim line). Are you using Outlook 2010, perhaps the code is not right for it?
 
Isskint, thank you for checking. I was trying it with Outlook Express but I can try on another machine that has a later version of outlook, probably 2007. That my evening planned :)
thanks again smiler44
 
Isskint, thank you for checking. I was trying it with Outlook Express but I can try on another machine that has a later version of outlook, probably 2007. That my evening planned :)
thanks again smiler44

If using Outlook Express, that is not the same as using Outlook (two completely different programs). So the code Isskint provided included this:

Dim myOlApp As Outlook.Application

which won't work with OE.

It might be possible if you use LATE BINDING

Dim myOlApp As Object

and then created it with

Set myOlApp = CreateObject("OutlookExpress.Application")

But then you would probably need to check for an error and conditionally instantiate it to Outlook.Application if OutlookExpress is not installed.
 
Isskint's code opened a new email. I need to work with an already open email. As they two outlooks are different I wont use express.

smiler44
 

Users who are viewing this thread

Back
Top Bottom