T
Teki
I use outlook 2003 with exchange server. When I receive mail from specific
email address I want to move it to specific folder based on string in subject
and than pare the subject of mail and create new user property with value
parsed from subject.
Now I have macro that is capable of parsing the subject and adding parsed
value to new user property and outlook rule that moves mail based on address
and subject.
Problem is that macro works fine and rule works fine, but together they
don't work correct.
It seems that when mail is received macro creates user property correctly,
but than mail is moved and the value in user property is lost (maybe because
of connection with exchange?). If I create separate rules - one that executes
macro and other that moves mail they work fine if I execute each one
individually (by hand). If they are executed automaticaly, when mail is
received user property is gone. (I've tried different combinations.. e.g.
rule 1 than rule 2, rule 2 than rule 1). It just wont work.
Any help would be appreciated.
Here is my macro code:
Sub Jira(MyMail As Outlook.MailItem)
Dim strID As String
Dim Item As Outlook.MailItem
Dim olNS As Outlook.NameSpace
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set Item = olNS.GetItemFromID(strID)
mailSubject = Item.Subject
posStart = InStr(mailSubject, "(")
posEnd = InStr(mailSubject, ")")
jiraIDLen = posEnd - posStart
jiraId = Mid(mailSubject, posStart + 1, jiraIDLen - 1)
Dim prop As Outlook.UserProperty
Set prop = Item.UserProperties.Find("JiraID")
If TypeName(prop) = "Nothing" Then
Set prop = Item.UserProperties.Add("JiraID", olText, True)
prop.Value = jiraId
Item.Save
End If
End Sub
Thnx.
email address I want to move it to specific folder based on string in subject
and than pare the subject of mail and create new user property with value
parsed from subject.
Now I have macro that is capable of parsing the subject and adding parsed
value to new user property and outlook rule that moves mail based on address
and subject.
Problem is that macro works fine and rule works fine, but together they
don't work correct.
It seems that when mail is received macro creates user property correctly,
but than mail is moved and the value in user property is lost (maybe because
of connection with exchange?). If I create separate rules - one that executes
macro and other that moves mail they work fine if I execute each one
individually (by hand). If they are executed automaticaly, when mail is
received user property is gone. (I've tried different combinations.. e.g.
rule 1 than rule 2, rule 2 than rule 1). It just wont work.
Any help would be appreciated.
Here is my macro code:
Sub Jira(MyMail As Outlook.MailItem)
Dim strID As String
Dim Item As Outlook.MailItem
Dim olNS As Outlook.NameSpace
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set Item = olNS.GetItemFromID(strID)
mailSubject = Item.Subject
posStart = InStr(mailSubject, "(")
posEnd = InStr(mailSubject, ")")
jiraIDLen = posEnd - posStart
jiraId = Mid(mailSubject, posStart + 1, jiraIDLen - 1)
Dim prop As Outlook.UserProperty
Set prop = Item.UserProperties.Find("JiraID")
If TypeName(prop) = "Nothing" Then
Set prop = Item.UserProperties.Add("JiraID", olText, True)
prop.Value = jiraId
Item.Save
End If
End Sub
Thnx.