VBA Code

Hi,

We are currently working on stream lining alot of our relative tasks and one of them is sending a standard reply to emails that come into our mail boxes via a macro.

We want the macro to reply to the sender with a new subject line, and a standard message body that we can define with in the macro.

Currently we have it working on forwarding but we are unable to get it working on the reply with a set body text.

Does anyone have any ideas as to how we can do this?

We are using Outlook 2000 and the macro editor with in it.

thanks david jacques

cmrecruitmentAsked:
Who is Participating?
 
David LeeConnect With a Mentor Commented:
Ok, here's your code modified to send a reply.  I also took the liberty of cleaning it up a bit.  Hope you don't mind.

Sub explorerNames()
    Dim MsgTxt As String, _
        myItem As MailItem, _
        myReply As MailItem
    MsgTxt = "You have selected items from: "
    For Each myItem In Application.ActiveExplorer.Selection
        MsgTxt = myItem.SenderName
        Set myReply = myItem.Reply
        'Use HTMLBody instead of Body on the next line if your messages are in HTML format
        myReply.Body = MsgTxt
        myReply.Send
    Next
End Sub
0
 
David LeeCommented:
Hi cmrecruitment,

Are you forwarding with a macro?  If so, then post the code I can show you how to modify it to send a reply.  

Cheers!
0
 
masoncooperCommented:
If you are trying to reply with a semi-custom message, you may want to try setting up a rule that replies using a template, I'm not sure what all you want your macro to do, but if it's just a bit of customization, this is the way to go.

Tools > Rules and Alerts > New Rule
Construct the rule to run based on your own criteria, but when you select an Action, choose "Reply using a specific template".  This allows you to choose a template that you can create that has fields to further customize the message beyond boilerplate text.
0
 
cmrecruitmentAuthor Commented:
Hi bluedevilfan,

here is our current code. It just a forwarding macro at the moment.

thanks david jacques

Sub explorerNames()
 
Dim myOlApp As New Outlook.Application
    Dim myOlExp As Outlook.Explorer
    Dim myOlSel As Outlook.Selection
    Dim MsgTxt As String
   
    Dim x As Integer
    Dim myNms As Outlook.NameSpace
    Dim myFolder As Outlook.MAPIFolder
    Dim myRecipient As Outlook.Recipient
    Dim myItem As MailItem
    MsgTxt = "You have selected items from: "
   
    Set myOlExp = myOlApp.ActiveExplorer
    Set myOlSel = myOlExp.Selection
    Set myItem = myOlSel.Item(1)
    For x = 1 To myOlSel.Count
              MsgTxt = myItem.SenderName
        Set myForward = myItem.Forward
        myForward.To = "davidj@candm.co.uk"
        myForward.Send
    Next x
End Sub
0
 
David LeeCommented:
Any update, cmrecruitment?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.