Steffen Winkler is right. I found a way in which my application can work in Outlook 2010 and 2013.
, . , . outlook 2007. .
, , Outlook 2010, , Outlook 2010. , , Int64, .
:
private void DragNDropArea_DragDrop(object sender, DragEventArgs e)
{
OutlookDataObject dataObject = new OutlookDataObject(e.Data);
string[] filenames = (string[])dataObject.GetData("FileGroupDescriptorW");
MemoryStream[] filestreams = (MemoryStream[])dataObject.GetData("FileContents");
for (int fileIndex = 0; fileIndex < filenames.Length; fileIndex++)
{
try
{
string filename = filenames[fileIndex];
MemoryStream filestream = filestreams[fileIndex];
string startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
if (Directory.Exists(startupPath))
{ }
else
{
Directory.CreateDirectory(startupPath);
}
FileStream outputStream = File.Create(startupPath + "\\" + filename + ".msg");
filestream.Seek(0, SeekOrigin.Begin);
filestream.WriteTo(outputStream);
outputStream.Close();
filestream.Close();
readMessage(filename, startupPath);
}
catch (System.Exception ex)
{
MessageBox.Show("Error Occured In getting Mail info..: \n" + ex.ToString());
}
}
}
OutlookDataObject.cs GetData() :
string[] fileNames = new string[fileGroupDescriptor.cItems];
IntPtr fileDescriptorPointer = (IntPtr)((Int64)fileGroupDescriptorAPointer + Marshal.SizeOf(fileGroupDescriptorAPointer));
for (int fileDescriptorIndex = 0; fileDescriptorIndex < fileGroupDescriptor.cItems; fileDescriptorIndex++)
{
NativeMethods.FILEDESCRIPTORA fileDescriptor = (NativeMethods.FILEDESCRIPTORA)Marshal.PtrToStructure(fileDescriptorPointer, typeof(NativeMethods.FILEDESCRIPTORA));
fileNames[fileDescriptorIndex] = fileDescriptor.cFileName;
fileDescriptorPointer = (IntPtr)((Int64)fileDescriptorPointer + Marshal.SizeOf(fileDescriptor));
}
" ".
:
Ribbon1.xml:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" loadImage="GetImage">
<contextMenus>
<contextMenu idMso="ContextMenuMailItem">
<button id="MyContextMenuMailItem"
label="OnePgr Integrator"
onAction="OnMyButtonClick" showImage="true" image="favicon.ico.ico"/>
</contextMenu>
<contextMenu idMso="ContextMenuMultipleItems">
<button id="MyContextMenuMultipleItems"
label="OnePgr Integrator" image="favicon.ico.ico"
onAction="OnMyButtonClick"/>
</contextMenu>
</contextMenus>
</customUI>
Ribbon1.cs:
public void OnMyButtonClick(Office.IRibbonControl control)
{
try
{
Outlook.Selection selectedMails = control.Context as Outlook.Selection;
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
MailItem, Outlook 2010, 2013 .
...!