Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-12-2015, 06:42 PM
BusinessBuilder BusinessBuilder is offline Tag incomming emails? Windows 8 Tag incomming emails? Office 2013
Novice
Tag incomming emails?
 
Join Date: Aug 2015
Posts: 8
BusinessBuilder is on a distinguished road
Default Tag incomming emails?

Hi,

I have a website from where I receive emails I have developed the system so


that it automatically adds a unique ticketnr to the subject line like 201500001.

And now I would like to ask if its possible to automatically add a tag to the email title for instance 2015DR00001 if people simply directly email to my emailadress. And then automatically increment on each NEW email. So a first email not a reply or something.

Is this possible and if so how can I do this?

I hope you can help me out here?
Reply With Quote
  #2  
Old 08-12-2015, 10:27 PM
gmayor's Avatar
gmayor gmayor is offline Tag incomming emails? Windows 7 64bit Tag incomming emails? Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It should be possible provided you can identify the messages you want to tag with a rule to process them as they arrive. The following macros store the incremented tag number in the registry (so the count is only maintained on one PC). The process them checks to establish if the last word in the subject of the message is a tag in the format - 2015DR00001 (where the first four digits are the year and the last 5 the incrementing number). If the message is not a reply with 'RE:' at the start of the subject the tag is added to the end of the subject.

Put the code in a new Outlook VBA module and run the script 'AddTag' from the rule.

I have included a macro to test the code on an existing message and another to remove the registry entry to reset the count after testing.

Code:
Option Explicit

Sub TestProcess()
'Graham Mayor www.gmayor.com
Dim olMsg As MailItem
    On Error Resume Next
    Set olMsg = ActiveExplorer.Selection.Item(1)
    AddTag olMsg
lbl_Exit:
    Exit Sub
End Sub

Sub AddTag(olItem As Outlook.MailItem)
'Graham Mayor www.gmayor.com
    If Not TagExists(olItem.Subject) Then
        olItem.Subject = olItem.Subject & " - " & Year(Date) & "DR" & AddNumber
        olItem.Save
    End If
lbl_Exit:
    Exit Sub
End Sub

Private Function TagExists(strSubject As String) As Boolean
'Graham Mayor www.gmayor.com
    If Not Left(strSubject, 3) = "RE:" Then
        strSubject = Mid(strSubject, InStrRev(strSubject, Chr(32)))
        If IsNumeric(Left(strSubject, 4)) And _
           IsNumeric(Right(strSubject, 5)) And _
           InStr(5, strSubject, "DR") > 0 Then
            TagExists = True
        End If
    End If
lbl_Exit:
    Exit Function
End Function

Private Function AddNumber() As String
'Graham Mayor www.gmayor.com
Dim TagNum As Long
    TagNum = GetSetting(appname:="E-Mail Tag", section:="Config", _
                        Key:="TagNumber", Default:="0")
    TagNum = TagNum + 1
    SaveSetting appname:="E-Mail Tag", section:="Config", _
                Key:="TagNumber", setting:=TagNum
    AddNumber = Format(TagNum, "00000")
lbl_Exit:
    Exit Function
End Function

Sub ResetNumbering()
'Graham Mayor www.gmayor.com
    DeleteSetting "E-Mail Tag"
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 08-13-2015, 03:43 AM
BusinessBuilder BusinessBuilder is offline Tag incomming emails? Windows 8 Tag incomming emails? Office 2013
Novice
Tag incomming emails?
 
Join Date: Aug 2015
Posts: 8
BusinessBuilder is on a distinguished road
Default

I allready run into the problems with the first assignment.

Put the code in a new Outlook VBA module and run the script 'AddTag' from the rule.

How do I do this? I was looking online but I don't see andy VBA module inside my
outlook.

Please advise.
Reply With Quote
  #4  
Old 08-13-2015, 03:56 AM
BusinessBuilder BusinessBuilder is offline Tag incomming emails? Windows 8 Tag incomming emails? Office 2010 32bit
Novice
Tag incomming emails?
 
Join Date: Aug 2015
Posts: 8
BusinessBuilder is on a distinguished road
Default

Ok. So now I found the developers tab. Yeah baby.

What's next?

Put the code in a new Outlook VBA module and run the script 'AddTag' from the rule.

How do I create a new VBA module and run the script 'AddTag' from the rule?

Thanks
Reply With Quote
  #5  
Old 08-13-2015, 04:23 AM
gmayor's Avatar
gmayor gmayor is offline Tag incomming emails? Windows 7 64bit Tag incomming emails? Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

From the VBA editor (ALT+F11 will open it) Insert > Module. Paste the code into that module. - Although aimed at Word the process described at http://www.gmayor.com/installing_macro.htm is almost identical and may help.

As for creating a rule - https://support.office.com/en-za/art...7-a50704d66c59

One of the options is run a Script and the script you want to run is AddTag, which will almost certainly be the only script listed to select. Set conditions to identify the particular messages or it will tag all incoming messages.

You can run the 'test' macro with a received message selected to test how it works.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #6  
Old 08-14-2015, 09:24 AM
BusinessBuilder BusinessBuilder is offline Tag incomming emails? Windows 8 Tag incomming emails? Office 2010 32bit
Novice
Tag incomming emails?
 
Join Date: Aug 2015
Posts: 8
BusinessBuilder is on a distinguished road
Default

Hi,

I can't find this part:
One of the options is run a Script and the script you want to run is AddTag, which will almost certainly be the only script listed to select. Set conditions to identify the particular messages or it will tag all incoming messages.

You can run the 'test' macro with a received message selected to test how it works.


Please advise?

Thanks a bunch.
Business Builder
Reply With Quote
  #7  
Old 08-14-2015, 08:44 PM
gmayor's Avatar
gmayor gmayor is offline Tag incomming emails? Windows 7 64bit Tag incomming emails? Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Undelivered emails help marshy36 Outlook 0 02-18-2015 09:23 AM
Tag incomming emails? Can only see emails no later than two weeks old! HELP! rdunlap Outlook 1 07-07-2014 11:04 AM
Are my emails gone? hrockwel Outlook 0 04-25-2012 07:30 PM
Tag incomming emails? Outlook emails are marked as spam, but Gmail emails are not. aquabob Outlook 1 07-28-2010 11:41 AM
Tag incomming emails? Emails Bcc zizou Outlook 2 11-29-2005 07:02 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft