Automatic response system

Hi EE,

I have been given the task of creating an autoresponse email for people who email us.   Any email coming from our customerservice email address automatically receives an autoresponse that advises them that their email has arrived.  I need to find a way so that the subject line in the autoresponse contains an automatic number which the recipient can use as a reference number.

For example, if we receive an email from our website form to the customerservice email address, the autoresponse would say something like this:

Subject line: Confirmation of email - reference number: YYMMDD-<autonumber>

Your email has been received....blah blah blah etc...

Is this possible?

Thanks.
Terry.
TerenceHewettAsked:
Who is Participating?
 
David LeeCommented:
Terry,

Sorry to be slow in getting this to you, especially since the change is so minor.  Here are the instructions for setting this up and using it.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code below and paste it into the right-hand pane of the VB Editor window
5.  Edit the code making the changes per the comments I embeded in the code
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools->Macro->Security
9.  Set the Security Level to Medium.  
10.  Close Outlook
11.  Create the file to hold the sequence number and seed it with a starting number.
12.  Start Outlook
13.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.
14.  Test the macro by having someone send you a message.  
15.  When the message arrives the macro will run and generate a response.  You should receive a dialog-box saying that an application is accessing your email and asking if you want to allow it to.  Say yes.  When the macro sends the response you'll see another dialog-box saying an application is trying to send a message and asking for your permission to allow it to.  Say yes again.  These dialog-boxes are a part of Outlook's built in security made necessary by the many viruses and worms that have been written to use it as a transport mechanism.  There are various ways to get around all or part of them depending on what version of Outlook you use.  First, you can sign the code.  Here's a link to instructions on doing that: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/odc_dsvba.asp
Second, you can use ClickYes (http://www.contextmagic.com/express-clickyes/), a small utility that'll click the Yes button for you.  It creates a security hole though, since a virus could start sending messages and ClickYes would click the Yes button for it too.  Third, disable Outlook's security features.  I wouldn't recommend that one.



'Macro Begins Here
Private WithEvents objInboxItems As Items

Private Sub Application_Startup()
    Dim objNS As NameSpace
    Set objNS = Application.GetNamespace("MAPI")
    Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
    Set objNS = Nothing
End Sub

Private Sub Application_Quit()
    Set objInboxItems = Nothing
End Sub

Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
    Dim objFSO As FileSystemObject, _
        objFile As TextStream, _
        intReferenceNumber As Integer, _
        olResponse As Outlook.MailItem, _
        strResponseFileName As String, _
        olReply As Outlook.MailItem
    'Change the file and path name on the next line as needed
    strResponseFileName = "C:\eeTesting\ResponseNumber.txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(strResponseFileName)
    intReferenceNumber = CInt(objFile.ReadLine)
    If intReferenceNumber = 0 Then
        intReferenceNumber = 1
    Else
        intReferenceNumber = intReferenceNumber + 1
    End If
    objFile.Close
    Set objFile = objFSO.OpenTextFile(strResponseFileName, ForWriting)
    objFile.Write intReferenceNumber
    objFile.Close
    Set objFile = Nothing
    Set objFSO = Nothing
    Set olResponse = Application.CreateItem(olMailItem)
    Set olReply = Item.Reply
    With olResponse
        .To = olReply.Recipients(1)
        'Change the following 2 lines as needed.  If you want to send an HTML response, then change .Body to .HTMLBody
        .Subject = "Confirmation of email receipt. Your reference is: " & intReferenceNumber
        .Body = "We received your email."
        .Send
    End With
    Set olResponse = Nothing
    Set olReply = Nothing
End Sub
'Macro Ends Here
0
 
will_scarlet7Commented:
Would you be looking to build your own customised Auto reply?
http://www.experts-exchange.com/Applications/MS_Office/Outlook/Q_21098069.html
0
 
TerenceHewettAuthor Commented:
Hi Sam,

Thanks for your post. Maybe the link from one of your old responses will help me, but I am basically looking for a solution so that each auto-response goes back out to the recipient with a different reference ID in the subject heading. For example:

A message has come in to my inbox from a customer. That customer receives an auto-response that says something like "thanks for your message. we confirm receipt and will be in touch."

Within that auto-response, I would like the subject heading to contain a reference number (but different for each auto-response sent out.  For example:

Auto-reply 1 : Subject: Confirmation of email receipt. Your reference is: 12345
Auto-reply 2 : Subject: Confirmation of email receipt. Your reference is: 12346
Auto-reply 3 : Subject: Confirmation of email receipt. Your reference is: 12347
and so on...

Does the above make any sense to you?

Any help would be appreciated.

Many thanks,
Terry.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
will_scarlet7Commented:
Hi Terry,
   The actual solution from my previous auto-reply solution would not likely fit your situation. I mainly posted it to show how a custome reply solution could be built using VBA, which is the only way that I know of to develop something that does the type of custom actions that you are refering to.

There might be a simpler solution, but my suggestion would be:
1.) Create a Custom Reply MACRO in VBA
2.) Connect to an Access database to get a unique reply reference number and record that number, along with details about the email replied to.

I'm preparing to catch a train to the Airport in a few hours, so I would not be able to get into the nuts and bolts of such a system today, but perhaps (if no one else is able to supply you with and alternative solution, and you can wait) I could work on it a bit tomorrow and through the end of the week.

God bless!

Sam
0
 
TerenceHewettAuthor Commented:
Hi Sam,

I would really appreciate your help with this. I am in no immediate rush, and would welcome anything that you could offer.  Not a professional in VBA, although I have dabbled in VBA for MS Access in the past.

Thanks again for all your help and advice.

Have a safe journey.

Best wishes,
Terry.
0
 
David LeeCommented:
Terry,

I've written the macro below that will generally do what you requested.  To make it fully functional I need to know what version of Outlook you'll be using it with.  I'll make final code changes and post instructions on how to set it up and use it as soon as you provide the Outlook version.

'Macro Begins Here
Private WithEvents objInboxItems As Items

Private Sub Application_Startup()
    Dim objNS As NameSpace
    Set objNS = Application.GetNamespace("MAPI")
    Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
    Set objNS = Nothing
End Sub

Private Sub Application_Quit()
    Set objInboxItems = Nothing
End Sub

Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
    Dim objFSO As FileSystemObject, _
        objFile As TextStream, _
        intReferenceNumber As Integer, _
        olResponse As Outlook.MailItem, _
        strResponseFileName as String
    strResponseFileName = "C:\eeTesting\ResponseNumber.txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(strResponseFileName)
    intReferenceNumber = CInt(objFile.ReadLine)
    If intReferenceNumber = 0 Then
        intReferenceNumber = 1
    Else
        intReferenceNumber = intReferenceNumber + 1
    End If
    objFile.Close
    Set objFile = objFSO.OpenTextFile(strResponseFileName, ForWriting)
    objFile.Write intReferenceNumber
    objFile.Close
    Set objFile = Nothing
    Set objFSO = Nothing
    Set olResponse = Application.CreateItem(olMailItem)
    With olResponse
        .Subject = "Confirmation of email receipt. Your reference is: " & intReferenceNumber
        .To = Item.SenderName
        .Body = "We received your email."
        .Send
    End With
    Set olResponse = Nothing
End Sub
'Macro Ends Here
0
 
TerenceHewettAuthor Commented:
Hi Blue Devil,

Thanks for your post.  The version of Outlook is 2003.  I will try this code in the office tomorrow and let you know how it goes.

Regards,
Terry.
0
 
David LeeCommented:
Hi, Terry.

I need to refine the code a little for Outlook 2003.  The code I posted above was a general approach to show one way of accomplishing this.  Butthe method of addressing a return message is different in 2003 than it was in 2002/2000.  I also need to explain a bit about Outlook security and how to implment the macro, unless of course you're already familiar with those topics.
0
 
TerenceHewettAuthor Commented:
Hi Blue Devil,

Any advice would be great on the Outlook security for 2003. I can use Outlook for its intended person, but when it comes to programming...I am pretty much a novice, although I have done some VBA in Excel and Access.

Thanks,

Terry.
0
 
will_scarlet7Commented:
Terry & BlueDevilFan,

Another thing to get around the Security nags (especially since the "send" nag makes you wait 30 seconds before you can click "Yes") would be to install Outlook Redemption, and use it's objects in the code for the replies...

Sam

PS. Terry, sorry I could not get to this sooner. My trip ended up not giving me as much free time as I initialy anticipated. Glad BlueDevilFan was around to step in.
0
 
TerenceHewettAuthor Commented:
Hi Sam and BlueDevilFan - hey it rhymes...a double act in the making!

Glad you had a safe journey sam and no problems in not having time to look at this for me.   Thanks BlueDevilFan for your help with the above. I have not had time to look at this as I have been away for a while, but will try the suggested coding above. If I have further problems, I will send a new post.

Best regards to both,

Terry
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.