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.
Related
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.
I am trying to help people do their job. So every morning an email needs to go out to the users with a list to Approve/Reject... Don't want to send this email just like a warning, telling them to go to the app to perform their duty. The email needs to have the capability to capture their response and update the DB accordingly.
option 1: Embed all items in single email body as a form, something like...
Code - Description - radiobutton - radio button
111 ABC o Accept o Reject
222 DEF o Accept o Reject
Submit
On submit need to call a winforms app and need to pass the code and accept/reject status. I have not been able to find any thing to come up with a solution. Need to validate as well, making sure all appropriate radio buttons have been selected. Is it even possible?
Option 2: I am trying to avoid voting route where each item will go as a separate email. when the user will accept/reject, a reply will go to the email. Then some process will monitor that inbox and will pick the not read messages and update DB accordingly. Using the MailItemClass in Microsoft.Office.Interop.Outlook namespace.
var mailItem = (Outlook.MailItem)Application.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.To = "some.address#server.com";
mailItem.Subject = "This is a test";
mailItem.Body = "This is the body of the message.";
mailItem.VotingOptions = "Accept; Reject;";
mailItem.Send();
I believe what you are asking for is possible but would be a lot of effort to implement.
For your approach, I assume the information for these emails comes from the DB. I would write a macro to interrogate the DB and create and send each email to the appropriate user.
On each user’s system I would have a rule that recognised these emails and called a macro to process them. The macro would extract the contents of the email, copy it to a form and pass control to the user. A Submit button would validate the user’s choices and save the results in global variables before returning control to the macro. On regaining control, the macro would update the DB.
This macro will be large and I am sure it will need maintenance. To protect itself from malware, Outlook does not provide any easy way of importing macros. The macro and the form will have to be manually imported to each user’s system, each time they change. Unless you have technically able users, it will be you who visits each system and updates it.
I would reject any approach that required code on the user’s systems.
To test an alternative approach, I manually created this email:
and sent it to myself. When I received the email, I actioned it as instructed. When I received the reply, it looked like:
The Html body for this reply is full of formatting information. You could extract the responses from it but I believe the text body would be easier. To create the following, I started with the text body, replaced every carriage return and line feed with [CR] and [LF] and then added a few new lines to make it marginally easier to read.
[CR][LF][CR][LF] [CR][LF][CR][LF]From: Tony Dallimore [mailto:a.j.dallimore#MyIsp.com] [CR][LF]Sent: 25 May 2018 14:22[CR][LF]To: 'Tony Dallimore' <a.j.dallimore#MyIsp.com>[CR][LF]Subject: Test email 2[CR][LF][CR][LF] [CR][LF][CR][LF]
Please:[CR][LF][CR][LF] [CR][LF][CR][LF]
1) Click Reply within the Home tab.[CR][LF][CR][LF]
2) You may find it helpful to click Pop Out.[CR][LF][CR][LF]
3) Enter “A” in the Accept column or “R” in the Reject column of every row in the following table.[CR][LF][CR][LF]
4) Click Send.[CR][LF][CR][LF] [CR][LF][CR][LF]Code[CR][LF][CR][LF]Description[CR][LF][CR][LF]Accept[CR][LF][CR][LF]Reject[CR][LF][CR][LF]
111[CR][LF][CR][LF]ABC[CR][LF][CR][LF]A[CR][LF][CR][LF][CR][LF][CR][LF]
222[CR][LF][CR][LF]DEF[CR][LF][CR][LF][CR][LF][CR][LF]R[CR][LF][CR][LF]
333[CR][LF][CR][LF]GHI[CR][LF][CR][LF]A[CR][LF][CR][LF][CR][LF][CR][LF]
444[CR][LF][CR][LF]JKL[CR][LF][CR][LF]A[CR][LF][CR][LF] [CR][LF][CR][LF]
[CR][LF][CR][LF] [CR][LF]
You would need a second macro to process these emails, extract the responses and update the DB. There is no validation on the user’s system but they are not being asked to do anything complicated. If you telephone and harangue them every time you get an incomplete reply, they will soon realise life is more pleasant if they get it right first time.
I do not know how difficult it is to access your DB from VBA but I do not believe anything else is particularly difficult.
This is not the approach you requested but I believe this will be very much easier to implement. More importantly, all the code is on your system which will make development and maintenance so much easier.
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
This is a theoretical question but any specific technical knowledge that could help will also be appreciated.
I am an IT Assistant with not much knowledge in programming (apart from EasyPattern and super-simple batch files) but have been given an opportunity to start getting into it by having been given a task to create a step in our document management system which is vaguely defined by the title of this question.
CONTEXT:
So, we have incoming faxes with short digit codes on them, these code correlate to identifying information in our database (relevantly; email addresses). In a watched folder environment we have software that upon auto-acknowledging these fax/image files being dropped into a designated incoming location (from a fax server) it initiates Microsoft Digital Imaging (MODI, runs in the background) to find these codes (using OCR, Optical Character Recognition) and places them into CSV files (one .csv file per code per fax page). Our database admin assures me that he can have the email addresses that correlate to the codes automatically placed into their correlating csv file.
GOAL:
It is from this point that I am being asked to find a way to have a universal unchanging email message ("We have received your fax") automatically sent to those email addresses. Upon a "way" being known, I am then to actually accomplish it.
QUESTION:
How to do this? As I said, a valid theoretical answer will suffice, for that will tell me how it can be done, which would in turn tell me what to learn, which would in turn tell me where to look.
WHERE I'M AT NOW:
I understand VBA to be a programming model within an 'event-driven' paradigm and that VBA programming projects are possible and supported in both Microsoft Outlook and Access. Does herein lie my answer? Can VBA used to accomplish this? (maybe auto import the email addresses from the csv file into the "To:" field of a outgoing email?) I'm hoping it'll be easier since the message can always stay the same (something along the lines of: We received your message). I'm reading two text books that introduce the reader to VBA in Access with one, and VBA in Outlook with the other.
I hope this message makes sense, this whole question might be naive, incoherent, or maybe even outright ignorant. But any patient and understanding response would be GREATLY appreciated.
You want something like this.
For posterity's sake, here is a summary of what it entails:
In Outlook, add a handler for the Application-level NewMailEx event.
Load each MailItem by its EntryID and handle it appropriately.
You would create your new email with Application.CreateItem(oMailItem), define its subject/body/recipients and then send it.
I was just introduced to the concept of Outlook forms. I don't know if this will solve my problem but here is what I want to do:
I want to be able to have employees who are inside the company fill out some forms. So all I have to do is create the form and PUSH it to their Outlook? After they fill out the form, can I capture the data somehow? Has anyone does this before? Can someone recommend a good tutorial/examples?
Update: The Outlook->Access option seems like a great one, but it seems like the form must be emailed by someone. In other words, if someone wants to fill out any form they first have to be emailed a form. What if a person wants to just fill out a form? How would he do it if he has no access to the Access database?
Here are three options:
This page is a really good jump page for custom forms in Outlook. In fact, that whole site is pretty good with lots of examples and links like Outlook Forms Step-by-Step Tutorial.
However, if you also have Access 2007, I'd actually recommend something simpler and easier to create email forms that can be sent to users and collect back all of the information. Once I discovered this in Access 2007 I never went back to custom Outlook forms.
Basically, you create an Access db with the data you want to collect and then in the "External Data" tab in Access 2007, you click "Create E-mail" and a wizard will walk you through creating an email with the form in the body (which is either HTML or InfoPath, depending on which one you choose). You send this to your users (you can have a recipient list in a table as well in your Access DB) and they fill out the form (I used it for surveys) and then they click submit. It goes back to your Outlook in a special folder and as soon as you open Outlook, it will synch it with the database. Then you can slice and dice all of that database information.
Here are some great tutorials on this:
Demo: Collect data in Access 2007 by
using e-mail
How to integrate Microsoft Access
and Outlook 2007
Finally, if you just want to collect back much simpler information, like "Yes", "No", "Maybe", the easiest way is to create voting buttons. Go to New Message -> Options - Voting Buttons. You can customize this if needed by separating your choices with a semi-colon ;.
In #2 and #3 above, these are scenarios to initiate data collection.
There are other situations where someone doesn't need a prompt via email to fill something out right there, but rather just submit a form (like an expense report, or a gas mileage report). #1 above (Outlook custom forms) is generally better choice in that scenario, but:
Outlook forms have typically been
harder to deploy and teach people to
use (there are things like "public
forms", "private forms", etc.)
Outlook forms have been, in practice,
been replaced by other technologies.
In particular, InfoPath/Forms Server and
Sharepoint Forms. This is because neither
of those two technologies requires
users to do a whole lot other than
follow a link to fill out a form. I used to know, about 10 years ago, many companies who tried to use Outlook forms and most of them gave up development of them in favor of other technologies.
This isn't to say that Outlook forms are bad in any way. If you don't have other technologies available to serve as a Forms Server, then this could be a decent option to consider.
To look at other semi-lightweight ways of form submission, you can use MS Word templates as the front end and have them update an Access DB. Here are a couple of good articles on this:
Import Data Directly from Word
Forms to Access Tables
How do I... Transfer data from a
Word form to an Access database?