PDA

View Full Version : Send response mail after categorizing



daloercher
12-15-2019, 11:48 AM
Dear all,

I wrote a macro that sends an responsemail (to the sender), with its content being different depending on what category the mail is assigned to. At the moment I have to manually trigger this macro.
Now I am wondering if it is possible to have the response mail send automatically upon categorizing.
It would mean that the assignment of the category starts the macro.

Has anyone ever done something like this ?
Any hint or help I'd be thankful for.

Best Regards

Daniel

gmayor
12-16-2019, 03:10 AM
You could use a rule to identify and categorise the message as it arrives and use a macro script assigned to that rule to create the appropriate response and send it.

daloercher
12-18-2019, 12:42 AM
Hi,

the assignment of the category is done manually. the reason for this is that this is the inbox for a group of people. One of those persons will assign the email to the members of this group. This depends on who has time to take care of the subject, who knows how to do this kind of task and several other factors.

As described after the assignment of the category I would love to respond to the sender who will take care of the issue.

gmayor
12-18-2019, 05:47 AM
In that case you can assign the categories with a macro and reply accordingly e.g. as follows. Change the categories and the texts as required.


Option Explicit

Sub CategorizeAndReply()
Dim objMail As MailItem
Dim olItem As MailItem
Dim olInsp As Inspector
Dim wdDoc As Object
Dim oRng As Object
On Error Resume Next
Select Case Outlook.Application.ActiveWindow.Class
Case olInspector
Set objMail = ActiveInspector.currentItem
Case olExplorer
Set objMail = Application.ActiveExplorer.Selection.Item(1)
End Select
objMail.ShowCategoriesDialog
If Not objMail.Categories = "" Then
Set olItem = objMail.Reply
With olItem
.BodyFormat = olFormatHTML
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range(0, 0)
.Display
Select Case objMail.Categories
Case "Category name 1"
oRng.Text = "This is the message for Category name 1" & vbcr & vbcr & "More message text" 'etc
Case "Category name 2"
oRng.Text = "This is the message for Category name 2"
Case "Category name 3"
oRng.Text = "This is the message for Category name 3"
Case "Category name 4"
oRng.Text = "This is the message for Category name 4"
'etc
End Select
'.Send
End With
Else
Beep
MsgBox "No category assigned"
End If
lbl_Exit:
Set objMail = Nothing
Set olItem = Nothing
Exit Sub
End Sub