Code for Replying to Selected Msg 
Author Message
 Code for Replying to Selected Msg

I'm trying to setup some outlook macros for my department to reduce work on
repeative tasks.  I'm a bit of a newbie at outlook objects, but I've manage
to code just about everything I want my macro to do except for the most
basic thing.  I can't figure out how to reply to the currently selected
message!!  I know this seems like a basic thing, but I think I'm messing up
my objects.  So, HELP!  thanks.

HockeyBoy



Thu, 14 Jul 2005 06:37:52 GMT  
 Code for Replying to Selected Msg
Try this:

    Set objOL = CreateObject("Outlook.Application")
    Set objExp = objOL.ActiveExplorer
    Set objItem = objExp.Selection(1)
    Set objReply = objItem.Reply

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming: Jumpstart
     for Administrators, Power Users, and Developers
     http://www.slipstick.com/books/jumpstart.htm

Quote:

> I'm trying to setup some outlook macros for my department to reduce work on
> repeative tasks.  I'm a bit of a newbie at outlook objects, but I've manage
> to code just about everything I want my macro to do except for the most
> basic thing.  I can't figure out how to reply to the currently selected
> message!!  I know this seems like a basic thing, but I think I'm messing up
> my objects.  So, HELP!  thanks.

> HockeyBoy



Thu, 14 Jul 2005 06:56:36 GMT  
 Code for Replying to Selected Msg
Sweet, thanks.  Actually I was really close, I didn't know about the (1)
about .selection.  You know why that is there?  Help never mentioned
anything about it.

I try to insert the text from the previous email in the reply (so it looks
like a normal reply) but it only manages to copy straight text, no HTML.
Anyway to fix this?  I use:

    objreply.HTMLBody = "Text Here" & Chr(13) & Chr(13) & objitem.HTMLBody

...but it still doesn't pick up the HTML.  Am I doing something wrong?

One last thing, how do I insert the signature using VB?  Again, help doesn't
mention a thing about it, but there must be a way.  Thanks for all your
help.

HockeyBoy



Try this:

    Set objOL = CreateObject("Outlook.Application")
    Set objExp = objOL.ActiveExplorer
    Set objItem = objExp.Selection(1)
    Set objReply = objItem.Reply

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming: Jumpstart
     for Administrators, Power Users, and Developers
     http://www.slipstick.com/books/jumpstart.htm


Quote:
> I'm trying to setup some outlook macros for my department to reduce work
on
> repeative tasks.  I'm a bit of a newbie at outlook objects, but I've
manage
> to code just about everything I want my macro to do except for the most
> basic thing.  I can't figure out how to reply to the currently selected
> message!!  I know this seems like a basic thing, but I think I'm messing
up
> my objects.  So, HELP!  thanks.

> HockeyBoy



Sun, 17 Jul 2005 14:33:43 GMT  
 Code for Replying to Selected Msg

Quote:
> Actually I was really close, I didn't know about the (1)
> about .selection.  You know why that is there?  Help never mentioned
> anything about it.

Selection is a collection. If you want just one item, you can specify the index number. If you want multiple items, you loop through the collection with a For Each ... Next loop.

Quote:
> I try to insert the text from the previous email in the reply (so it looks
> like a normal reply) but it only manages to copy straight text, no HTML.
> Anyway to fix this?  

If you have Outlook set to include the original message text in the reply, it should already be there, even when you generate the reply with the Reply method.

Quote:
> I use:

>     objreply.HTMLBody = "Text Here" & Chr(13) & Chr(13) & objitem.HTMLBody

> ...but it still doesn't pick up the HTML.  Am I doing something wrong?

Remember this is HTML! What you add needs to use HTML tags, not normal string techniques. Also, you need to insert into the <body> element; you can't just append text to an HTML documents. I don't have a good code sample to demonstrate this, but will see about putting one together.

Quote:
> One last thing, how do I insert the signature using VB?  Again, help doesn't
> mention a thing about it, but there must be a way.  Thanks for all your
> help.

Forget about "there must be a way" when it comes to Outlook, unless you're willing to work hard to develop workarounds. See the thread on "VBA code to insert signature on e-mail" in this group starting 1/17.
Quote:



> Try this:

>     Set objOL = CreateObject("Outlook.Application")
>     Set objExp = objOL.ActiveExplorer
>     Set objItem = objExp.Selection(1)
>     Set objReply = objItem.Reply



> > I'm trying to setup some outlook macros for my department to reduce work
> on
> > repeative tasks.  I'm a bit of a newbie at outlook objects, but I've
> manage
> > to code just about everything I want my macro to do except for the most
> > basic thing.  I can't figure out how to reply to the currently selected
> > message!!  



Sun, 17 Jul 2005 19:42:36 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Code for Replying to Selected Msg

2. Preventing Reply or Changing Reply Address

3. Setting the selected option of a select box in code

4. Code to set Chart Y Axis value - Reply to SteveT

5. Need code to convert PlainText to RichText/HTML format when replying

6. Setting reply address via code

7. HOW TO in VB :Outlook MSG DROP in Explorer creates a MSG File

8. VBA code to save email messages (.msg) to hard drive

9. Access a .msg file with code

10. i input code from office xp Inside Out and get error msg

11. Looking for a Gradient OCX or code THAT DOES NOT GIVE AN ILLEGAL ACTION MSG

12. VBA Code for Selecting Header and Updating Fields Codes

 

 
Powered by phpBB® Forum Software