Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Outlook Macro needed that can copy itself into a folder on the mailbox when flagged.

Hi,

Outlook Macro needed that can copy itself into a folder on the mailbox when flagged.
And delete itself once i remove the flag.

I have these flagged mails within my Pst's that do not show up when i am working through OWA. So want these flagged mails to copy itself to a mailbox folder and when remove the flag delete itself.

Regards
Sharath
Avatar of David Lee
David Lee
Flag of United States of America image

Sharath,

I don't understand what you're asking for.  Macros cannto copy themselves to anything.  They have to be manually added to Outlook and they only work in the full version of Outlook, not OWA.
Avatar of bsharath

ASKER

Sorry Put it wrong...

I want a macro that can copy itself. ( I mean the mail ) that i flag to a folder. Then delete the mail when i remove the flag.


That helps, but this still won't work for OWA.  OWA cannot run macros at all.  There is no such concept there.
Ya i know but this will be helpful for me to have all my flagged mails in one mailbox folder even when my rules move them to the pst > Folders.

So this can be seen in the OWA when required...
Sorry, but I'm lost.  You said, "when i am working through OWA." which sounds as if you want the macro to do what you described when you are working in OWA.  That's impossible since macros don't work in OWA.  So, if you are working in OWA and flag an item it is NOT going to "copy itself into a folder on the mailbox".  And if you remove the flag from an item while in OWA the item is NOT going to "delete itself".  Both of these can work in Outlook, but not in OWA.
Ok... Let me reexplain..

At office or at home when i use outlook i flag mails that needs followup and move them to a folder on my mailbox. i cannot move all as due to the rules they move into folders into the pst. So in times when i am in home where i dont have access to my Psts or when i am out some where where i need to access the mails through OWA. n these 2 situations i want my mails to be on the server in my To do folder thats on the mailbox.

Now
As soon as i receive a mail they drop into my inbox. After which i run a rule that you gave me to move them to folders in my PST. So before i run the rule macro i flag all that needs an update.
So what i want is as soon as i flag want a copy of the mail flagged and moved to my mailbox > to do folder. So when i am done i can unflag them and they are deleted. So in this case i have completed the job and unflagged but i still have the mail safe in my inbox or other folders where the mail was moved.
I am afraid that doesn't help.  What I'm stumped on is what OWA has to do with this process.  If you want the flagging and deleting done in Outlook, not OWA, then I don't understand why OWA is even being mentioned.  It just confuses the question.  

If I understand right what you're asking for is a macro that will

1.  Move an item to a specific folder when that item is flagged in Outlook.
2.  Delete an item from a specific folder when an item's flag is cleared in Outlook.

Do I have it right?
Yes you are right...
I want a copy to be moved not the mail itself.
Sorry for the OWA confusion question...
Remind me of which Outlook version you're using.
I am using office 2007
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank U..

I have put this code into thisoutlooksession
Then created a folder called actions in the inbox.

Then change this line as this
 Set olkFolder = OpenOutlookFolder("inbox\Actions")

Is all the above right?
But when flagged no mail is copied...
Did you close and restart Outlook?  If not, please do so.
After i closed and opened the outlook i get this.

The folder name actions is just below the inbox. On the mailbox (Server)
ScreenShot017.jpg
Are you sure the folder path you entered on line 19 is correct?  Does it include the name of the mailbox or personal folder the folders are in?  Remember that folder paths begin at the root.  If the folders are in your mailbox then the path should be something like

    Mailbox - Sharath\Inbox\Actions
Got it works fine...
But when i remove the flag it does not get deleted.
When i flag both the inbox copy as well as the actions folder copy are flagged and when i remove and add the flag on the mail in the inbox there are duplicate copies into actions folder...

As you mentioned
>>Instead of using flagging to accomplish this I'd use a separate bit of code that's run from a toolbar button.  That'd solve both problems at once.

Can you let me know what is the other way...
Hi Any help....
"When i flag both the inbox copy as well as the actions folder copy are flagged"
Which I mentioned as a problem in the post with the code.

"when i remove and add the flag on the mail in the inbox there are duplicate copies into actions folder"
Of course.  Removing the flag on the copy in the Inbox does nothing.  Only clearing the flag in the destination folder causes it to be deleted, and then only the copy in the destination folder.  When you flag the item again the script makes another copy in the destination folder.

"Can you let me know what is the other way..."
Sure.  Actually there are two other approaches.

1.  Create a toolbar button and use it trigger the action.  Clicking the button would flag and copy all the selected items to the destination folder without flagging any of the items in the Inbox.  Rather than unflag the item to delete it, just delete it.  Toolbar buttons are only available in Outlook, not OWA, but then so are macros.

2.  Create a custom Outlook form for this.  This is not the best approach, but would allow you to use flagging.  That's because the code would be in the form itself which would overcome the problem associated with trying to do this via a macro.