Copy content from table in a mail to another mail using VBA in outlook? - vba

I am trying to get started with VBA in outlook and I was wondering if anyone had code that copied and pasted the content of one cell from a table in an outlook mail to another mail (only the content - not the cell or table)?
A small piece of example code would be great.
Best regards

It looks like you need to parse the message body and find the required value. Then paste it to another message body.
The Outlook object model provides three main ways for working with item bodies:
Body.
HTMLBody.
The Word editor. The WordEditor property of the Inspector class returns an instance of the Word Document which represents the message body. So, you can use the Word object model do whatever you need with the message body.
See Chapter 17: Working with Item Bodies for more information.
Also you may find the Getting Started with VBA in Outlook 2010 article helpful.

Related

Outlook VBA - Automate Replies in Specific Folder

First time poster and new to Outlook VBA.
I currently have a rule that moves all incoming mail that contains the string “Apple” in the body to a specific folder.
I ultimately want this:
On any new email that gets moved to that folder, if the body does NOT contain the word “fruit” then reply with “Deny”, a line break and then a couple sentences. The original subject and body should remain. It would act the same as if I hit the “Reply” button.
I’m getting stuck here, thank you!

Microsoft Word - Send to Mail Recipient - custom subject

I want to override the native Send To Mail Recipient behavior in MS Word 2007/2010 to customize the subject of the email message. Is this possible? I can write the VBA macro to replicate the functionality, but is it possible override/customize the native behavior?
Assuming you are trying to manipulate the hyperlink on email addresses in Word, the only thing you can preset it is the Subject.
Right click on the link in Word, click Edit Hyperlink...:
Then type in the customized email Subject:
Now with VBA, you can see the link is now including the subject. This means that you can use VBA to alter all the Hyperlinks.
?activedocument.Hyperlinks.Item(1).Address
mailto:someone#there.com?subject=Customized%20Subject%20for%20the%20email
Note the spaces are now %20, so you may need another function to convert other non-alphabets.
Hope this is what your Native means.

Macro/Script - Set Forward Blue Line as Reference to delete previous emails when forwarding without manually deleting the previous emails

Seeking your insight on this process:
I want to forward the latest email received only not including the entire thread of the emails. Can I forward that email without manually deleting the previous emails on the thread?
I want to automatically send the NEWEST/LATEST emails received to a specific email address without the previous emails on the thread.
What I'm thinking is, I will set the "BLUE LINE" as reference, for starting position and ending position. Because as we all know, whenever we forward a HTML email, there's a blue line separating emails received.
Is it possible to do that? Set blue line as reference, then delete everything not inside the lines.
You can edit the message body at runtime using VBA macros. The Outlook object model provides three main ways for working item bodies:
Body - a string representing the clear-text body of the Outlook item.
HTMLBody - a string representing the HTML body of the specified item.
Word editor - the Microsoft Word Document Object Model of the message being displayed. The WordEditor property of the Inspector class returns an instance of the Document class from the Word object model which you can use to set up the message body.
You can read more about all these ways in the Chapter 17: Working with Item Bodies. It us up to you which way is to choose to customize the message body.
If you are new to VBA macros, see Getting Started with VBA in Outlook 2010.

Change hyperlink based on date in Outlook 2013

Every day our Helpdesk has to send out a report. That report needs to link to a website that displays that days statistics.
Example URL:
http://hostname/dashboardname/date
Which would look like this:
http://hostname/HelpdeskTickets/2015-03-18
Heres what I've tried:
First I looked into field code values and doing something like this
{HYPERLINK "http://hostname/HelpdeskTickets/{DATE \# "yyyy-MM-dd"}"}
And this works, until you close the outlook message. If you don't have F9 to update the field code, and save and close the .msg file it will disappear leaving just the blank link without a date. If you hit F9 before closing it, it puts that days date into the field, however when you close and save it the field code disappears and leaves the date in place of the date field code. Also I noticed this problem doesn't happen in word. You can save and close a word file and it keeps the field codes.
Another thing I've tried is to use VBA to edit the links in the message body. So far nothing has actually worked.
The only thing that partially worked was taking the body of the document and using a string replace function on it. However this destroys all formatting and hyperlinks along with it.
I'm open to any ideas on how this can be achieved.
My main problem is that the people at the helpdesk can't seem to use anything that isn't fool proof. So having them press F9 before sending this email was actually scaring people that they wouldn't be able to do that.
You can use VBA to edit the message body programmatically. It is not clear what code you used earlier, but the main ways are described below:
HTMLBody - a string representing the HTML body of the specified item. The HTMLBody property should be an HTML syntax string.
The Word editor. The WordEditor property of the Inspector class returns an instance of the Document class from the Word object model. So, the message body is represented by the Word Document.
You can read more about all possible ways in the Chapter 17: Working with Item Bodies.

How to change salutation for multiple recipients in Outlook with c#

I want to code an outlook addin and try to replace a placeholder in an outlook mail with the salutation of the recipient. I get the salutation from AD. I tried this in ItemSend, but the body for different recipients contains always the last replacement.
Then i generated a new mail per recipient. That seems to be the right way, but there is the next problem. The mailitem.htmlbody contains not the same content like shown in the outlook message window. All styles of the original message are lost and for instance my signature is bad formatted.
Has anyone an idea to solve my problem?
First of all, if want to send an individual "salutation" for each recipient you need to send separate emails. For example, you can check out the list of recipients in the ItemSend event and if it contacts more than one entry in the collection you can cancel the send operation setting the Cancel parameter to true and prepare an individual email to each recipient from the collection.
You may consider using the Word object model instead of modifying the raw HTML markup of the body. The WordEditor of the Inspector class returns an instance of the Document class from the Word object model. The Chapter 17: Working with Item Bodies describes all possible ways of working with item bodies.