Link to home
Start Free TrialLog in
Avatar of jennywatts
jennywatts

asked on

Change the status of an email to 'replied to' using a macro.

I have used the code below which was posted by BlueDevil for auto replying to selecte emails and it works great.  However, I need some additional code which will reply to the email (code below works well) and then will change the status of the email to 'replied to'.  At present the code works, but I have no way of knowing which emails have received a reply and which ones haven't.  Any urgent assistance that can be given I would be grateful.  Here's what I have so far from BlueDevil:

Sub SendCannedResponse()
    Dim olSelection As Outlook.Selection, _
        olResponse As Outlook.MailItem, _
        olReply As Outlook.MailItem, _
        objItem As Object
    Set olSelection = Application.ActiveExplorer.Selection
    For Each objItem In olSelection
        If objItem.Class = olMail Then
            Set olResponse = Application.CreateItem(olMailItem)
            If Left(Application.Version, 2) = "11" Then 'Outlook 2003
                olResponse.Recipients.Add objItem.SenderEmailAddress
            Else 'Some version of Outlook prior to 2003
                Set olReply = objItem.Reply
                olResponse.Recipients.Add olReply.Recipients.Item(1).Address
                Set olReply = Nothing
            End If
            olResponse.Subject = "CV Received"
            olResponse.Body = "We received your CV and are processing it."
            olResponse.Send
            Set olResponse = Nothing
        End If
    Next
    Set objItem = Nothing
    Set olSelection = Nothing
End Sub
Avatar of David Lee
David Lee
Flag of United States of America image

Hi jennywatts,
> I have no way of knowing which emails have received a reply and which
> ones haven't

Sorry, but I don't understand what you're looking for.  Any message that is replied to is automatically marked as having been replied to.  The statement I quoted suggests that what you are really looking for is a means of determining which of your replies have been replied to.  If so, then there is no means of doing that with any certainty.  If not, then I don't understand what you want to accomplish.  Could you explain a bit more?

Cheers!
BDF

Don't be cruel - just give her another macro!  :-)
I'll offer that up as soon as I understand what she's looking to accomplish.
Avatar of jennywatts
jennywatts

ASKER

The problem I am having is that when I use the macro it does send a reply, but the original email does not then get automatically marked as 'replied' (with the little arrow).  Even if I open one email and then run the macro it still isn't showing the email as having been replied to - it just shows as if it were a new email that has not been opened.  I am looking for a way in the macro to force it to change the status:

1.Reply to all the selected emails (this bit works fine).
2.Change the status of the selected/highlighted emails to 'replied'.

I realise that all emails that have been replied to should show automatically as replied, but this isn't happening.

Any urgent help please!
Ok, sorry for my confusion.  Try this macro instead.

Sub SendCannedResponse()
    Dim olSelection As Outlook.Selection, _
        olResponse As Outlook.MailItem, _
        objItem As Object
    Set olSelection = Application.ActiveExplorer.Selection
    For Each objItem In olSelection
        If objItem.Class = olMail Then
            Set olResponse = objItem.Reply
            olResponse.Subject = "CV Received"
            olResponse.Body = "We received your CV and are processing it."
            olResponse.Send
            Set olResponse = Nothing
        End If
    Next
    Set objItem = Nothing
    Set olSelection = Nothing
End Sub
Hi,

That's exactly what I needed - perfect - thanks.  Just one more thing - I think this is fairly straightfoward and it has just occurred to me?  Could the code be extended to delete the emails that have been sent by the macro which will be stored in the sent items (there will be a rather large volume of these being sent and I am a bit worried that the user will clog up their sent items folder).
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent - it worked exactly the way I needed it to.  Thanks BlueDevilFan
You're welcome.
Help again please!!!
I am using the code above an it is working fine on my personal mailbox, but I need to use this on another mailbox which has been locked out by Exchange server from sending messages.  When I try to run the macro I am getting a System Administrator Undeliverable message.  What I really need to do is use this macro (send a standard email, mark the original email with 'replied' and have the email sent from me (or whoever is using the macro).  Then I need the macro to delete from my Sent Items (or whoever is sending the mail Sent Items).
Urgent please as I needed to have this finished by this morning.

Thanks
jennywatts,

> When I try to run the macro I am getting a System Administrator Undeliverable message.
I expect that's because the message you are replying to is in a mailbox that has been locked out by the Exchange server.  You can only reply to messages that are in your folders.  If you have been delegated access to another mailbox and reply to a message in it, then you are replying on behalf of the other mailbox owner.  In other words, you are using their account to reply, not your own.  There's no way I know of to get around that.

> What I really need to do is use this macro (send a standard email, mark the original email with 'replied' and have the email sent from me (or whoever is using the macro).  
As I noted above, I don't know of any way to do this if you are replying to a message in a mailbox you are accessing through delegation.

Assuming that I've understood correctly, then I'm sorry, but I don't know of any way to do this.