Add a subject to a new email with custom button - outlook

I wrote an Add-in for Outlook 2010 that inserts text to a new email subject and to the email body. The working code is shown below.
Later I added a custom group to the built-in new email message tab ribbon and added a button using the default name Button1. When I run the add-in the button shows up fine.
I want to click on this button and change the subject and the body content. I tried to add a private sub Button1_Click with code that changes the subject to “subject example” and the body to “body example” and could not make it work. Can you add to the ribbon code the Button1_Click sub that will do that? See below the Addin code and the ribbon1 code.
Public Class ThisAddIn
Private WithEvents inspectors As Outlook.Inspectors
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
inspectors = Me.Application.Inspectors
End Sub
Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
End Sub
Private Sub inspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles inspectors.NewInspector
Dim mailItem As Outlook.MailItem = TryCast(Inspector.CurrentItem, Outlook.MailItem)
If Not (mailItem Is Nothing) Then
If mailItem.EntryID Is Nothing Then
mailItem.Subject = "This text was added by using code"
mailItem.Body = "This text was added by using code"
End If
End If
End Sub
End Class
Ribbon1 Code without the Private Sub Button1.Click. Please show me how to write this code.
Public Class Ribbon1
Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load
End Sub
End Class

VSTO provides two main ways for customizing the Ribbon UI:
Walkthrough: Creating a Custom Tab by Using the Ribbon Designer
Walkthrough: Creating a Custom Tab by Using Ribbon XML
Essentially you need to add the onAction attribute for the button and then add the corresponding callback to the code.
Read more about the Fluent UI (aka Ribbon UI) in the following series of articles in MSDN:
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)
To get the currently shown in the inspector window Outlook item you can use the ActiveInspector method of the Application class or use the IRibbonControl.Context property which you may cast to the Inspector class. Then you can use the CurrentItem property to get the Outlook item.

Related

How to add custom property to InternetHeaders of Outlook MailItem

I need to add custom InternetHeader x-auth-guid to existing MailItem in Outlook inbox (in Exchange account) from VSTO add-in. Something like described here
https://learn.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2010/dd633654(v=exchg.80)
but without EWS.
The code using EWS work and do something like:
extendedFieldURI.propertyName = "x-auth-guid"
extendedFieldURI.distinguishedPropertySetId = "InternetHeaders"
property.extendedFieldURI = extendedFieldURI
property.value = xauthGuid
message.addExtendedProperty(property)
But in add-in both PropertyAccessor like:
mailItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/x-auth-guid", xauthGuid);
mailItem.Save();
and Redemption
rdoMail.Fields["http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/x-auth-guid"] = xauthnGuid;
rdoMail.Save();
seems don't work. Am I missing something?

Dynamics 365 Get Guid Button

Does anyone know of a managed solution to import into Dynamics 365 that adds functionality for a custom button to copy the Guid of any entity to your clipboard?
In a previous environment we used this one
Of course this can't be imported into the newer Dynamics 365.
I know how to parse out the Guid from the URL, but the button to autocopy it to the clipboard was amazing.
The Chrome Extension Level Up has button for Record Id, or you can use the bookmarklet code. Just add the below code to a bookmark in your browser:
//get record id
javascript: (function () { var form = $("iframe").filter(function () { return $(this).css("visibility") == "visible" })[0].contentWindow; window.prompt("Copy to clipboard: Ctrl+C, Enter", form.Xrm.Page.data.entity.getId().slice(1, -1)) })();
Try Level Up for Dynamics 365 Chrome Extension, it provides a great variaty of common JScript actions and shortcuts to help with extensibility, diagnostics and administration
if what you need is to pulish an option to your user to get the GUID of a record and prevent the execution of other JS logic such as display all hidden attributes, then you will have to create a ribbon button and execute JS logic contained in a webresource, to make it compatible with CRM v9 and forward, past the execution context to your function (PrimaryControl) and call the native Xrm function executionContext.getFormContext().data.entity.getId()
Another extremely useful Chrome called Dynamics Power Pane. Use it together with Level Up for Dynamics 365 will be very powerful.

Outlook VSTO form does not display in release version (installed)

Thanks for looking.
I am working on an Outlook plugin that includes a pop-up Form that loads a browser inside of it to allow the user to log in via a 3rd party auth service.
This works great when running from a debug session: I see the custom tab in the ribbon, click the "login" button, and the form pops up as a modal using .ShowDialog().
I am using Outlook 2016.
Problem
When I publish this VSTO and then install it on my machine, the plugin loads and I can see the "login" button in the custom ribbon tab, but clicking it does nothing. I have checked to be sure that the dialog isn't simply popping under the main form. If it's there--I can't find it.
Back to debug session--everything works great. I suspect a permissions issue, but I don't get any prompts or errors from Outlook.
Last, I don't know if it's related, but I sent the VSTO installer to a colleague and they get the following error when attempting to install:
System.Security.SecurityException: Customized functionality in this
application will not work because the certificate used to sign the
deployment manifest for {APP NAME REMOVED} or its location is not
trusted. Contact your administrator for further assistance.
Any help is greatly appreciated.
Most probably your form is shown behind the Outlook window. You need to specify the parent window handle if you want to see the form all the time on top of Outlook windows. The Show and ShowDialog methods of the System.Windows.Forms.Form class allows to specify the parent window handle by passing an instance of the IWin32Window interface as a parameter.
First, you need a class which implements that interface:
public class WindowWrapper : System.Windows.Forms.IWin32Window
{
public WindowWrapper(IntPtr handle)
{
_hwnd = handle;
}
public IntPtr Handle
{
get
{
return _hwnd;
}
}
private IntPtr _hwnd;
}
In Outlook you can cast an instance of the Explorer or Inspector class to the IOleWindow interface and get the window handle which can be used for the IWin32Window implementation.

how can i migrate or cast the CommanBar control to new VSTO controls?

I want to pass the control for the new VSTO button click.
I want to migrate this to new VSTO ribbon click. How can I do this?
I am using the ribbon.xml where i have added a onAction event
onAction="Ribbon3_Click"
public bool Ribbon3_Click(Office.IRibbonControl control)
{
xsComp.myRibbon3_Click();
return true;
}
and the method I am calling is
public void myRibbon3_Click(Core.CommandBarButton Ctrl, ref bool CancelDefault)
It is hitting the error to pass the argument. How can I do this?
I am using .net c# 4.0 VSTO addin for Office 2010.
Seems you have some problems with arguments. I checked my ribbon button handlers and they have a signature like this:
private void Button_OnClick(object sender, IRibbonControl control, bool pressed)
Yours only accepts the IRibbonControl. And when you call your myRibbon3_Click, you call it with no arguments while the signature tells you need to pass it two arguments.

Clear Categories in Outlook 2003

Outlook 2007 automatically strips categories from incoming email.
Outlook 2003 does not do this, forcing the recipient to use the senders categories.
Is there a way to either:
Force Outlook 2003 to remove the categories (can't do it via Rules and Alerts) on incoming email.
OR
Force both Outlook 2007 and Outlook 2003 to remove categories before sending?
Thanks,
Jeff
Try setting up a rule to run a script:
Sub RemoveCategories(MyMail As MailItem)
Dim strID As String
Dim objMail As Outlook.MailItem
strID = MyMail.EntryID
Set objMail = Application.Session.GetItemFromID(strID)
objMail.Categories = ""
objMail.Save
Set objMail = Nothing
End Sub
This is based on this article.

Resources