Work in progress for better mail alerts

This commit is contained in:
gamosoft_cp 2013-03-30 00:35:37 +00:00
parent 2be99c0798
commit 35a65fc9bb
10 changed files with 399 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,146 @@
namespace Outlook2013TodoAddIn
{
partial class NewMailAlert
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblSender = new System.Windows.Forms.Label();
this.lblSubject = new System.Windows.Forms.Label();
this.txtBody = new System.Windows.Forms.TextBox();
this.btnDelete = new System.Windows.Forms.Button();
this.btnFlag = new System.Windows.Forms.Button();
this.btnEnvelope = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblSender
//
this.lblSender.AutoSize = true;
this.lblSender.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblSender.Location = new System.Drawing.Point(85, 11);
this.lblSender.Name = "lblSender";
this.lblSender.Size = new System.Drawing.Size(52, 17);
this.lblSender.TabIndex = 0;
this.lblSender.Text = "label1";
//
// lblSubject
//
this.lblSubject.AutoSize = true;
this.lblSubject.Location = new System.Drawing.Point(85, 28);
this.lblSubject.Name = "lblSubject";
this.lblSubject.Size = new System.Drawing.Size(46, 17);
this.lblSubject.TabIndex = 1;
this.lblSubject.Text = "label1";
//
// txtBody
//
this.txtBody.Location = new System.Drawing.Point(88, 49);
this.txtBody.Multiline = true;
this.txtBody.Name = "txtBody";
this.txtBody.ReadOnly = true;
this.txtBody.Size = new System.Drawing.Size(214, 77);
this.txtBody.TabIndex = 2;
//
// btnDelete
//
this.btnDelete.BackgroundImage = global::Outlook2013TodoAddIn.Properties.Resources.Delete;
this.btnDelete.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.btnDelete.Location = new System.Drawing.Point(50, 94);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(32, 32);
this.btnDelete.TabIndex = 6;
this.btnDelete.UseVisualStyleBackColor = true;
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
//
// btnFlag
//
this.btnFlag.BackgroundImage = global::Outlook2013TodoAddIn.Properties.Resources.Flag;
this.btnFlag.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.btnFlag.Location = new System.Drawing.Point(12, 94);
this.btnFlag.Name = "btnFlag";
this.btnFlag.Size = new System.Drawing.Size(32, 32);
this.btnFlag.TabIndex = 5;
this.btnFlag.UseVisualStyleBackColor = true;
this.btnFlag.Click += new System.EventHandler(this.btnFlag_Click);
//
// btnEnvelope
//
this.btnEnvelope.BackgroundImage = global::Outlook2013TodoAddIn.Properties.Resources.Envelope;
this.btnEnvelope.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.btnEnvelope.Location = new System.Drawing.Point(16, 17);
this.btnEnvelope.Name = "btnEnvelope";
this.btnEnvelope.Size = new System.Drawing.Size(60, 60);
this.btnEnvelope.TabIndex = 8;
this.btnEnvelope.UseVisualStyleBackColor = true;
this.btnEnvelope.Click += new System.EventHandler(this.btnEnvelope_Click);
//
// btnClose
//
this.btnClose.BackgroundImage = global::Outlook2013TodoAddIn.Properties.Resources.Delete;
this.btnClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.btnClose.Location = new System.Drawing.Point(282, 8);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(20, 20);
this.btnClose.TabIndex = 9;
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// NewMailAlert
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(314, 140);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnEnvelope);
this.Controls.Add(this.btnDelete);
this.Controls.Add(this.btnFlag);
this.Controls.Add(this.txtBody);
this.Controls.Add(this.lblSubject);
this.Controls.Add(this.lblSender);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NewMailAlert";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "NewMailAlert";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblSender;
private System.Windows.Forms.Label lblSubject;
private System.Windows.Forms.TextBox txtBody;
private System.Windows.Forms.Button btnFlag;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.Button btnEnvelope;
private System.Windows.Forms.Button btnClose;
}
}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Outlook2013TodoAddIn
{
public partial class NewMailAlert : Form
{
public Microsoft.Office.Interop.Outlook.MailItem Email { get; set; }
public NewMailAlert(string sender, string subject, string body)
{
InitializeComponent();
this.lblSender.Text = sender;
this.lblSubject.Text = subject;
this.txtBody.Text = body;
}
private void btnDelete_Click(object sender, EventArgs e)
{
this.Email.Delete();
this.Close();
}
private void btnFlag_Click(object sender, EventArgs e)
{
//Microsoft.Office.Interop.Outlook.OlFlagIcon.olYellowFlagIcon
this.Email.FlagRequest = "Follow up";
this.Email.Save();
this.Close();
}
private void btnEnvelope_Click(object sender, EventArgs e)
{
this.Email.Display();
this.Close();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -185,6 +185,12 @@
<Compile Include="FormRecurringOpen.Designer.cs">
<DependentUpon>FormRecurringOpen.cs</DependentUpon>
</Compile>
<Compile Include="NewMailAlert.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="NewMailAlert.Designer.cs">
<DependentUpon>NewMailAlert.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@ -203,6 +209,9 @@
<EmbeddedResource Include="FormRecurringOpen.resx">
<DependentUpon>FormRecurringOpen.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="NewMailAlert.resx">
<DependentUpon>NewMailAlert.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -244,6 +253,15 @@
<ItemGroup>
<None Include="2012-11-20_1546.png" />
</ItemGroup>
<ItemGroup>
<None Include="Delete.png" />
</ItemGroup>
<ItemGroup>
<None Include="Flag.png" />
</ItemGroup>
<ItemGroup>
<None Include="Envelope.png" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18010
// Runtime Version:4.0.30319.18033
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -60,6 +60,36 @@ namespace Outlook2013TodoAddIn.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Delete {
get {
object obj = ResourceManager.GetObject("Delete", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Envelope {
get {
object obj = ResourceManager.GetObject("Envelope", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Flag {
get {
object obj = ResourceManager.GetObject("Flag", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -118,6 +118,15 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Envelope" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Envelope.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Flag" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Flag.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="todoIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\2012-11-20_1546.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

View File

@ -1,6 +1,7 @@
using Microsoft.Win32;
using System;
using System.Linq;
using System.Windows.Forms;
using Office = Microsoft.Office.Core;
namespace Outlook2013TodoAddIn
@ -33,6 +34,7 @@ namespace Outlook2013TodoAddIn
/// <param name="e">EventArgs</param>
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Globals.ThisAddIn.Application.NewMailEx += Application_NewMailEx;
this.AddRegistryNotification();
this.AppControl = new AppointmentsControl();
@ -52,6 +54,29 @@ namespace Outlook2013TodoAddIn
// TODO: Make sure there are no memory leaks (dispose COM objects)
}
private void Application_NewMailEx(string EntryIDCollection)
{
Microsoft.Office.Interop.Outlook.MailItem newMail = Globals.ThisAddIn.Application.Session.GetItemFromID(EntryIDCollection) as Microsoft.Office.Interop.Outlook.MailItem;
if (newMail != null)
{
string sender = newMail.Sender.Name;
string subject = newMail.Subject;
string body = newMail.Body;
NewMailAlert nm = new NewMailAlert(sender, subject, body);
nm.Email = newMail;
nm.Top = 0;
nm.Left = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - nm.Width;
// this.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
nm.Show();
if (nm.WindowState == FormWindowState.Minimized)
{
nm.WindowState = FormWindowState.Normal;
}
nm.Focus();
nm.BringToFront();
}
}
/// <summary>
/// Store the new size setting upon resizing
/// </summary>