Macro to mark email as read and move to folder - vba

I'm a complete beginner with macros in Outlook, but I would like to create a macro which marks an email as read, and moves it to a specific folder. Any help most welcome. I have searched to see if this precise request has been answered elsewhere, but haven't been successful.
Many thanks,
Bevis

Note, in Outlook you can create a rule or quick action to get the job done.
If you decide to go with VBA macros you need to set up the UnRead property and call the Move method to move the item to the required folder. You may find the Getting started with VBA in Office article helpful.

Related

Outlook VBA - How to get email item from user input

Although Im quite experienced with Excel VBA, Im not so much in regards of Outlook VBA (started yesterday, literally), so Im uncertain on how to get this simple task accomplished:
I created some coding to get a specific e-mail from the Inbox and then parse it and forward - that part is all good and well. Currently the code autodetects and retrieve the e-mail item using a set of parameters to filter through the Inbox. However, now I need to expand this code so that it can work with any e-mail item, and not only with that specific e-mail.
My idea is to get the user to input which e-mail item he/she wants to parse and forward, instead of getting the code to look in a specific place. How can that be done? The user input methods that I use regularly are InputBox (which returns a string) and GetOpenFileName, none of them suitable to pointing to a mail item within Outlook.
I thought about making the code work with the currently open e-mail item, but often the users have several e-mail items opened at once - forcing them to leave only one open for the code to work is not viable. Also, the code will be ran by people who have little to no IT expertise, so requesting things such as paths is also not an option. Is there any method for this?
I figured that working with Active MailItem is the way to go, as #niton suggested as well. I used a coding very similar to the one in this post, although I had to develop the handlers in case the user has other types of Objects active at the moment (AppointmentItems, for instance) or have multiple items selected. Final solution wasn't that much elegant - I was wishing for some sort of system input box where the user could point to the mail or something, but this works.

auto copy text from outlook emails and paste into another program

I dont know much about programming/developing. But I am facing a dilemma at my job. About each day I have to spend 20-30 minutes doing a manual repetitive task.
open email, copy text from email, outlook.
paste copied text into another app
Instead of doing this manually: opening each email, copy text and paste the text to the matching record into the other app I was hoping this could be all done automatically.
The email matches with the other app record based off two unique control numbers.
Looking at this site, I see this question asked
Automatically export specific emails to text file from Outlook
But I am hoping anyone could maybe provide what might be the best plans to do this: not the actual steps but what language(s) could I learn that would automate the process for me.
Outlook does not like macros/programs, other than its own macros, looking at its emails. It is possible to get around this dislike but doing so will not be easy. Since you are not experienced, I believe the only suitable programming language is Outlook VBA; that is, you must write a macro to export text within Outlook.
An Outlook email can carry a text body and or an html body and or a rtf body. I have never seen a rtf body but the capability is there within Outlook. If an email has both an html and a text body, the user will see the html body. In my experience, the text body will be little more than the html body with all the formatting removed. If the html body is fairly simple, this can still give a useful text body for a macro to play with. But if the html body uses tables, for example, the text body can be useless.
How will you identify the emails from which text is to be extracted? (1) You can select one or more emails and then call a macro to process the selected emails. (2) You can run a macro at intervals to run down the Inbox looking for particular emails and process those. (3) There are more advanced techniques but get either approach 1 or 2 working then research “Outlook events”. If technique 1 appeals, look at the answer below then research "Outlook explorer". If technique 2 appeals, look at the answer recommended below.
Questions about extracting parts of emails are not uncommon. The problem with answering them is the difficulty of getting the questioner to understand that seeing an image of an email tells us little about the html that created that image. The macro in the answer below was written partly for my own research and partly to help others see the text and html bodies of their emails so they can better understand the processing required to meet their objective.
The macro in the answer, creates an Excel workbook and writes to it selected properties of selected emails. As written, the macro outputs details of every email in Inbox but contains comments explaining how to restrict output to the emails of interest. Start with this macro which contains a lot of material that you will find useful even if you decide the Outlook Explorer technique better meets your needs.
https://stackoverflow.com/a/12146315/973283

Outlook search emails with specific word in subject in non-default email folder

Help please- I am a complete newbie at this - I have a folder called "Cel_Emails" at the same level as the default folders. It contains some emails , and I manually do a search for all emails in this folder and look for all emails containing the word "Example" in the subject line (at which point - it only shows those emails and hides all other emails in that folder).
I am trying to write a vba script to do this - but am failing miserably - can anyone please help ?
Thanks in advance
Kind of a repeat question, this will get you started. Get reference to additional Inbox
If you would like to know how to cycle through emails in a folder and open them based on a word in the subject i will edit my answer and post it below.

Outlook 2010 VBA code to copy only certain appointments from a shared calendar to another persons calendar that i have access to

I am at the copy and edit stage of using VBA and have searched and searched for a code which gets me close but I am used to using VBA for excel not for outlook.
I have a shared calendar which many people add to (internally), once this is complete at the end of the day the appointments relevant to certain external people are added to their calendars, at the moment this is done by manually copying the appointments to the external peoples calendars.
It there a way to write some code which will do this automatically?
All calendars are on outlook and shared via exchange.
Any help is appreciated.
Jon
The Namespace class provides the GetSharedDefaultFolder method which returns a Folder object that represents the specified default folder for the specified user. So, you can access a shared calendar and copy/move items. To get the job done you need to use the Copy and Move methods in the following way, a raw sketch:
Set myCopiedItem = myItem.Copy
myCopiedItem.Move myNewFolder
Finally, you may find the Getting Started with VBA in Outlook 2010 article in MSDN helpful.

VBA Edit SharePoint Discussion Post (PostItem) and Update Web Discussion

I have a SharePoint discussion board sycned to Outlook 2010.
I want to be able to programmatically modify my posts within a SharePoint Discussion Board within Outlook VBA and have these changes reflected on the online discussion board.
The below code works in a test case to modify the items on the Outlook side but it is not synchronizing with SharePoint.
Private Sub modifySharePointItem()
Dim obj As Outlook.PostItem
Set obj = Application.ActiveExplorer.Selection.item(1)
obj.Body = obj.Body + "test addition"
obj.Save
obj.Post
End Sub
I am assuming I need to not just Save and Post but an additional "synchronize" type command but I do not know what it is.
Reading about the data model for PostItem was basically useless unfortunately and none of the methods seemed to do what I was interested in.
I found out (by accident.....) I am able to delete posts from Outlook - so I can obviously get much of the way here, but I still am unsure how to sync the lists when items are modified.
You can use the Client Object Model to do modifications and editing in Sharepoint. I do it all the time. Since Outlook 2010 compiles down to the CLI you could use the Client Object Model dlls to do what you need. I have a whole bunch of C# code that I could share if you need it. This is what I used to get started.
http://msdn.microsoft.com/en-us/library/ee537247(v=office.14).aspx
I hope that helps!