Is anyone aware of a technique I could use to override someone opening an email attachment within an outlook add-in?
Essentially what I'm being asked to do, is for certain attachments, to change the behavior so instead of opening the attachment the user is redirected to a webpage.
I can hook into the attachment context menu with Application.AttachmentContextMenuDisplay however that is not fired if the user simply double clicks on an email attachment.
Environment used is VS2010, c#, and outlook 2007/2010.
You should take a look at the ItemEvent BeforeAttachmentRead and BeforeAttachmentPreview. See this related post for reference.
((Outlook.ItemEvents_10_Event)MailItem).BeforeAttachmentRead += new Outlook.ItemEvents_10_BeforeAttachmentReadEventHandler(ItemEvents_BeforeAttachmentRead);
((Outlook.ItemEvents_10_Event)MailItem).BeforeAttachmentPreview += new Outlook.ItemEvents_10_BeforeAttachmentPreviewEventHandler(ItemEvents_BeforeAttachmentPreview);
Related
I'm writing an outlook addon that triggers when the Send button is sent on an email, if certain conditions are met a pop up comes up asking if the user is sure they want to send the email.
This works perfectly. However, A lot of emails that get sent are passed into outlook through another program and go into the drafts folder and are slowly sent out. Is there an Event handler for when an email is sent that doesn't rely on the send button being clicked?
EDIT:
I've found that the Send() method can be called to send an email - would it be possible to check if this method is called and when it is to run my code?
If the external app is using the Outlook Object Model to send the messages, Application.ItemSend event will still fire. Otherwise the best you can of is use Items.ItemAdd event on the Sent Items folder - it will trigger after a message is actually sent and moved to the Sent Items folder.
I want to be emailing with a Outlook add-in, I've followed as a previous user did:
Trying to Programmatically Create & Open a new Outlook Email
To create said email, but What if anything can I do to make it so outlook doesn't have this email pop-up on screen, and just sends it.
MailItem doesnt seem to have any kind of .Visible attribute that I'm aware of.
Is there a way to "hide" the Email? My add-in is set to a timer so it's sort of annoying for my system to pop up an email window on me every 30 minutes :/
Well, if you don't want to display the email, don't call Display. Call Send instead.
I have a small VSTO add-in that I've used with Outlook 2010 for some time. A move to Office 2013/Outlook 2013 is soon happening and so the add-in needs to be re-written to work with Outlook 2013.
The Outlook add-in is triggered by a custom ribbon button. When triggered, the add-in will create a new meeting request window and fill the message body with some custom content. After which the user can complete the meeting request and send it if they so desire.
The issue I'm currently having is that previously, this message window was created using the CommandBarControl object to programmatically trigger a click of the "New Meeting" button in Outlook. This worked in previous versions of Outlook, but I gather that the CommandBarControl object has been removed from Outlook 2013 and now fails silently. This is indeed what I am seeing.
The original code that was being used to create the new meeting request is this:
Explorer activeExplorer = Globals.ThisAddIn.Application.ActiveExplorer();
CommandBarControl commandBarControl = activeExplorer.CommandBars.FindControl(Type.Missing, 1106);
commandBarControl.Execute();
appointmentItem = (AppointmentItem)Globals.ThisAddIn.Application.ActiveInspector().CurrentItem;
appointmentItem.MeetingStatus = OlMeetingStatus.olMeeting;
appointmentItem.RTFBody = message; // message is a byte array being passed in from elsewhere.
The FindControl() method is used to find the "New Meeting" button in Outlook and then Execute() a click action on that button.
An alternative might be something like this:
appointmentItem = (AppointmentItem)Globals.ThisAddIn.Application.CreateItem(OlItemType.olAppointmentItem);
appointmentItem.MeetingStatus = OlMeetingStatus.olMeeting;
appointmentItem.RTFBody = message; // message is a byte array being passed in from elsewhere.
appointmentItem.Display(false);
The second code block will also create a new meeting request window and works in Outlook 2013, however there are a couple of subtle but important differences with the second code block...
The created meeting request will not inherit the date and time that a user has previously clicked on in their calendar, instead it will default to the current date/time regardless of what date/time the user has clicked on in their calendar.
The created meeting request will not respect the situation where a user is creating a meeting request "on behalf of" another user, because it ignores which calendar has been clicked on before the user initiated the new meeting request.
So my question is this: how can one now programmatically create (using a VSTO add-in) a new meeting request in Outlook 2013 that will respect which calendar the user has clicked on before hand? That is, it will satisfy the above two requirements that previously using the CommandBarControl object managed to satisfy?
You are right, Command bars were deprecated in Office 2010. Now the Fluent UI is used instead. You can read more about the new UI in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
You can run the required ribbon button programmatically using the CommandBars.ExecuteMso method (see the CommandBars property of the Explorer and Inspector classes). You just need to pass the idMso value of the built-in control you need to run. The following links provides lists of built-in controls for Office 2010 and 2013:
Office 2010 Help Files: Office Fluent User Interface Control Identifiers
Office 2013 Help Files: Office Fluent User Interface Control Identifiers
I am creating an Outlook add-in using C# that searches for a link in an HTML (new) email body signature when a user clicks on Send button in Outlook email. I am hooking into Application_ItemSend event. What's odd is that on my machine running XP/Outlook 2007 and in another Win7/Outlook 2007 machine, I am able to search for the link in the signature with no problems. But on some other Win7/Outlook 2007 machine, I am not able to search for the link because an additional span element is being inserted by Outlook.
For example, I am searching for Link in an HTML (new) email body. The link above is being inserted by a default signature so I am expecting to find it all the time. On some machines I am able to, on some machines I am not able to because the link appears like this:
<span style='color:blue'>Link</span>
I've rolled out a standard signature html file so the signatures for all machines are the same, but the issue still persists. I am still in the process of comparing the font/theme settings, but so far have seen no difference.
Does anyone have an idea on what's happening here?
Thanks.
I want to handle the hyperlink click event in an outlook mail. To open the hyperlinks in outlook mails without opening the browser within itself.
Does anyone know how to handle hyperlink click event on a mail item?
After searching a lot, I found that there is no way to catch the hyperlink click event in outlook.
If we want to catch a link we can define our own protocol url as follow.
http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx
Then using our own protocol handler we can catch the event.
If someone needs more information ask here.
Write an Outlook Add-in .net to handle that. To get the basic idea about writing an add- in look at the following link.
http://blogs.msdn.com/b/dancre/archive/2004/03/21/93712.aspx