I created a VBA code that will attach something at the end of every e-mail. I'm using:
With objItem
'.HTMLBody = .HTMLBody & "<p><p>" & TextID
End With
It usually works fine, but I detected that, when I generate an e-mail from a meeting (the meeting minutes/summary) it basically loses its format. I did a test & even simply doing a direct .HTMLBody = .HTMLBody won't keep the format.
This is the original e-mail:
/
This is the image after I apply this. Again, it only happens to e-mails generated from meetings.
/
Mi guess is that this is because appointment and meeting objects don't have the .HTMLBody property. So, my questions are:
Is my guess accurate?
Is there a simple workaround (that doesn't require a copy-paste from an e-mail or the inspector)?
Is there a way to detect that the e-mail I'm sending comes from a meeting?
but I detected that, when I generate an e-mail from a meeting (the meeting minutes/summary) it basically loses its format
Appointments (meetings) don't use the HTML based message bodies. Instead, the RTFBody property is available for them. You can use the StrConv function in Microsoft Visual Basic for Applications (VBA) or Visual Basic to convert an array of bytes to a string.
You can use a low-level on which Outlook is built - Extended MAPI. The PR_HTML property (DASL is http://schemas.microsoft.com/mapi/proptag/0x10130102) returns the HTML markup unlike the OOM.
But there is a universal solution - use the Word object model for dealing wit message bodies. See Chapter 17: Working with Item Bodies for more information.
Related
I have a VBA function in our MS Access database that generates Outlook emails and sends them from a shared inbox.
Our company uses Azure Information Protection to protect documents. A label needs to be applied to each email before it is sent (e.g. Public, Business Sensitive, Internal).
Rather than having the user click the label 25 times as it pops up for each email, I am trying to apply it programmatically.
I get error code (-1248837627).
My solution was to grab the labels GUID and then apply it to the email as below. I came across other solutions such as using SendKeys but I prefer it to be a last resort.
With olMail
.To = olSendTo
.Subject = olSubject
.PermissionTemplateGuid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
.Permission = olPermissionTemplate
'And so on, the email function works great until the above two lines are added
Am I applying the .Permissions or .PermissionTemplateGUID improperly?
I have seen a similar approach to apply labels to Excel documents (grabbing and setting the guid).
The code you posted is used to specify Information Rights Management (IRM) permissions. Azure Information Protection is another story.
You need to add a user property in the following format:
"MSIP_Label_" & guid_internal_use_only & "_Enabled"
But I'd suggest exploring internals of Outlook mail items using MFCMAPI or OutlookSpy to find the exact solution. Try to set it manually then explore internals using these tools.
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.
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
Plenty of info on incoming unsafe attachments but I've yet to find one that addresses my query on outgoing Outlook items.
I'm running a script that's sending large volumes of emails over Outlook and ideally i'd like to let it chug away all weekend: however last time I tried it got stuck when Outlook gave a prompt asking if I was sure I wanted to send the message since it might contain attachments that were unsafe.
It's very inconsistent: probably one in a thousand emails causes this and it doesn't seem to have any relation to the extensions of the attachments; which are exclusively PDFs, Docx, rtf, xlsx, html, or images.
So I'm dying for a way to either suppress the message, or build in something into the macro to circumvent it entirely, but I've absolutely no idea where to start since (as I said) all the search hits I get are only applicable to incoming mail items.
Help?!
Thanks!
There are two aspects of sending emails in Outlook:
Outlook security prompts. "Security" in this context refers to the so-called "object model guard" that triggers security prompts and blocks access to certain features in an effort to prevent malicious programs from harvesting email addresses from Outlook data and using Outlook to propagate viruses and spam. Read more about that in the Outlook "Object Model Guard" Security Issues for Developers article.
"Outlook blocked access to the following potentially unsafe attachments" message in Outlook.
I am writing an Outlook addin that inserts content into an email, and I have a emailSent event that I would like send an event back to my server letting me know some content was shared.
Is there a way to attach some meta information to the email (or the word doc, which is what you are creating in outlook) so that I can grab that meta info so I can send it back to my server.
Right now, the only way I think I can do it is to search through the email on the send event looking for my content with regex and pull out the info i need, but that seems cumbersome, and also means I need to run the regex for every email sent, even when they haven't added my content.
There is the concept of MAPI user properties, which you can add to an Outlook item. Since Office 2007 the object model allows access to them. If your add-in must run also with older Outlook version, you should recurr to use Redemption (which I prefer also for higher office versions because it has more flexibility, albeit a greater footprint in distribution).
See UserProperties Interface on MSDN.