A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Problem with macro running from rule



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old September 4th 08, 12:21 PM posted to microsoft.public.outlook.program_addins
Teki
external usenet poster
 
Posts: 1
Default Problem with macro running from rule

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.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to setup a rule to forward rule in Outlook (xp or 2003) to forward emails from a certain domain when app isnt running? KingCronos Outlook - General Queries 7 November 15th 06 11:22 AM
Problem running a VBA script from an Outlook rule Olivier Langlois Outlook and VBA 5 March 16th 06 09:03 PM
Problem running a VBA script from an Outlook rule Olivier Langlois Add-ins for Outlook 5 March 16th 06 09:03 PM
Running Macro Sanjeev kumar Kodavalla Outlook - Using Forms 2 March 5th 06 07:24 PM
Running a macro SuperSlueth Outlook - Using Forms 15 February 7th 06 09:51 PM


All times are GMT +1. The time now is 06:44 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.