Is there a way to reply to a sender with his own message? - vba

In outlook, I want all the people sending me emails with the object as "testintro" let's say, to be replied with their OWN email. I want them to receive exactly what they sent me. Is it possible to create that rule?

Yes, it is possible. But not with a rule. Instead, you can develop a VBA macro.
You can create a VBA macro where you could handle the NewMailEx event of the Application class. The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. Use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem.
So, you may get an instance of the arrived mail item and call the Reply method to reply instantly. The method creates a reply, pre-addressed to the original sender, from the original message. You may find the following articles helpful:
How To: Create and send an Outlook message programmatically
How To: Fill TO,CC and BCC fields in Outlook programmatically
How To: Change an Outlook e-mail message before sending using C# or VB.NET

Related

Use link from email outlook to fire VBA code

is there any chance to make the following scenario working
user gets email in Outlook containing link/text/object
clicking the object runs simple VBA code (i.e. replace string in txt) file on users computer
Thank you.
No, it is not possible. This is a potential path for malware.
Instead, you can handle the NewMailEx event of the Application class in Outlook VBA macros where can detect such mails (with a specific text or links) and run your business logic accordingly.
The NewMailEx event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item.

Custom Extended Properties on AppointmentItem is not available for Recipients

Before sending the appointmentItem in outlook 2010 I have created an extended property and set some values. The property is not available for the recipient (recipients are using outlook and they are from the same domain).
However, the property is available in the owner's calendar item.
Any inputs about this issue is much appreciated.
Keep in mind that ApointmentItem object is never sent - Outlook creates a MeetingItem object and sends. The original ApointmentItem remains in the Calendar folder.
You can try to use Application.ItemSend event - Outlook will pass MeetingItem as the parameter, and you should be able to set the extra properties. Now where these properties will be copied by Outlook from MeetingItem in the Inbox to the new ApointmentItem is a different question...
I have already replied to your post on MSDN forums two days ago:
The fact is that a meeting item is not sent to a recipient. Instead, a corresponding meeting request is created and sent to the recipient. Just check the message class of the item when the item is sent. You can handle the ItemSend event of the Application class which is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item.

How can the Add.Item event works at Outlook opening?

I got an issue with the macro I did in Outlook. To resume, the macro starts every time I receive an email. Then it will run a few others Sub, modify an Excel file and so one. When Outlook is running and I receive a new email, everything works perfectly. The problem occurs when I open Outlook and I receive more than one email at the same time.
I suppose the macro doesn't have enough time to end what it's doing with the first email and already try to start again with the next one.
Is there a way to keep the next emails in suspend in order to run the macro for each email, each one has its turn ? Or maybe you have another solution ?
Thank you.
PS: I can provide the code but it's very long.
The problem occurs when I open Outlook and I receive more than one email at the same time.
The NewMailEx event of the Application class is fired once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The EntryIDsCollection string contains the Entry ID that corresponds to that item.
The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item.
Make sure VBA macros are enabled and allowed to run when Outlook is started. Check out the Trust Center settings in Outlook.

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.

How to get notified when the message body is changed in an outlook addin?

I have an outlook add in that I want to be able to have a word counter or a notification to the user when the message body of the mailitem reaches a certain amount of words.
Is there any event similar to the Change-event that exists on the OlkTexxtBox for the _DDocSiteControl that could be used for this purpose?