Outlook: Auto-Reply to Person in Delivery Options "Have reply sent to" not the online service in the "From" field.

When I compile the solution (id 21738004) given by Bluedevilfan in Outlook 2007 (i.e. Version 12) (I'm using Microsoft Exchange also) I get a number of errors.  A missing End If and an End With that should have been an End If seems to sort some of it.  However the program stops on the Set redOriginal = CreateObject("Redemption.SafeMailItem") line with "The operation failed" message. Can someone fix this?
FaithfulWonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
Hi, FaithfulWon.

I can't find the question you referred to.  Can you supply a link to it?
0
FaithfulWonAuthor Commented:
Thanks for getting back to me.  I'm going home now from work.  I won't be looking at this again until tomorrow morning.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

David LeeCommented:
You're welcome.

I corrected the End If problems.  The other error

    redOriginal = CreateObject("Redemption.SafeMailItem")

is occuring because you don't have Outlook Redemption installed.  the author of the original question wanted to use it.  I can remove that portion of the code if you want, but that will cause problems if you are using Outlook 2003 or earlier.  Prior to 2007 Outlook contained a security feature that prevented code from sending messages or accessing email addresses without the user's permission.  Redemtion is one way to work around that.  If you have Outlook 2007, then removing the Redemtion specific code won't cause any problems.  If you're using Outlook 2003 or earlier, then removing the code will kill this as an automatic process.
'Macro Code Begins Here
Private WithEvents objInboxItems As Items

Private Sub Application_Startup()
    Set objInboxItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Application_Quit()
    Set objInboxItems = Nothing
End Sub

Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
    Dim redOriginal As Object, _
        redResponse As Object
    If Item.Class = olMail Then
        Set redOriginal = CreateObject("Redemption.SafeMailItem")
        redOriginal.Item = Item
        If redOriginal.SenderEmailAddress = "jobseekers@domain.com" Then
            Set redResponse = CreateObject("Redemption.SafeMailItem")
            With redResponse
                .Item = Application.CreateItem(olMailItem)
                .Recipients.Add redOriginal.ReplyRecipientNames
                'Replace the subject text on the following line with your subject
                .Subject = "My Subject"
                'Replace the body text on the following line with your text
                .Body = "My message."
                .Send
            End With
        End If
    End If
    Set redResponse = Nothing
    Set redOriginal = Nothing
End Sub

Open in new window

0
FaithfulWonAuthor Commented:
I am using Outlook 2007 so we don't need the redemption specific code.  However I'm not sure what that means in relation to changes to the code. Can you tell me which items need to be taken out?  I also don't want it to run every time the client is opened.  Can I use the code as an ordinary macro which is run from the Tools- Macro menu? Thanks for your help.
0
David LeeCommented:
"Can you tell me which items need to be taken out?"
I'll change the code.  

"I also don't want it to run every time the client is opened."
That will kill an automatic response.  In other words, you'll have to select a message and run the macro for a response to be sent.  Is that what you want?
0
FaithfulWonAuthor Commented:
I guess the complication arises from the fact that I want to run the macro on the inbox of another account -not the default- that is set up on the same Outlook 2007 client.  I've already had problems trying to do that to move attachments using a macro and had to use the PickFolder command to select the folder first.  I could reuse this code for auto replies as well but I'm not sure how it will work in the ThisOutlookSession module.

For the time being just send me the changed code and I'll experiment with it and get back to you with any problems.  Thanks.
0
David LeeCommented:
Here's the code modified to remove Redemption.

This code can be modified to run against a folder in another mailbox.  I included code and instructions for doing that.


'Macro Code Begins Here
Private WithEvents objInboxItems As Items

Private Sub Application_Startup()
    Dim olkRecipient As Outlook.Recipient

    'The next line tells the code to monitor the local inbox'
    Set objInboxItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items

    'The next series of lines tells the code to monitor a shared inbox'
    Set olkRecipient = Session.CreateRecipient("someone@company.com")
    olkRecipient.ResolveAll
    Set objInboxItems = Session.GetSharedDefaultFolder(olkRecipient,olFolderInbox).Items

    'Remove or comment out one of the two approaches above'

End Sub

Private Sub Application_Quit()
    Set objInboxItems = Nothing
End Sub

Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
    Dim olkResponse As Outlook.MailItem
    If Item.Class = olMail Then
        If Item.SenderEmailAddress = "jobseekers@domain.com" Then
            Set olkResponse = Application.CreateItem(olMailItem)
            With olkResponse
                .Item = Application.CreateItem(olMailItem)
                .Recipients.Add redOriginal.ReplyRecipientNames
                'Replace the subject text on the following line with your subject
                .Subject = "My Subject"
                'Replace the body text on the following line with your text
                .Body = "My message."
                .Send
            End With
        End If
    End If
    Set olkResponse = Nothing
End Sub

Open in new window

0
FaithfulWonAuthor Commented:
Hi BlueDevilFan, (is that name because you support Manchester City in the UK Premier League?),
I've been getting a number of errors as I test the new version related to objects not supporting methods.  For example the ResolveAll method is not supported in line 12 (an error message I cleared by changing ResolveAll to Resolve) and there is a similar problem on line 29 (a property or method not supported - RunTime error 438).  Also I don't understand the redOriginal expression in line 30.
0
David LeeCommented:
Sorry, I missed a couple of things that needed to be fixed.  Please try this version.

"is that name because you support Manchester City in the UK Premier League?"
No, but you aren't the first person to ask.  I'm a fan of Duke University in North Carolina.
'Macro Code Begins Here
Private WithEvents objInboxItems As Items

Private Sub Application_Startup()
    Dim olkRecipient As Outlook.Recipient

    'The next line tells the code to monitor the local inbox'
    Set objInboxItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items

    'The next series of lines tells the code to monitor a shared inbox'
    Set olkRecipient = Session.CreateRecipient("someone@company.com")
    olkRecipient.Resolve
    Set objInboxItems = Session.GetSharedDefaultFolder(olkRecipient, olFolderInbox).Items

    'Remove or comment out one of the two approaches above'

End Sub

Private Sub Application_Quit()
    Set objInboxItems = Nothing
End Sub

Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
    Dim olkResponse As Outlook.MailItem
    If Item.Class = olMail Then
        If Item.SenderEmailAddress = "jobseekers@domain.com" Then
            Set olkResponse = Application.CreateItem(olMailItem)
            With olkResponse
                .Recipients.Add Item.ReplyRecipientNames
                'Replace the subject text on the following line with your subject
                .Subject = "My Subject"
                'Replace the body text on the following line with your text
                .Body = "My message."
                .Send
            End With
        End If
    End If
    Set olkResponse = Nothing
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FaithfulWonAuthor Commented:
It took a few iterations but the solution does what I need now.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.