i develop in Delphi 10.3 (RIO), writen outlook add-in using add-in-express ver 9.x i want to chach just "selected" files from attachment list.
i add button to adxRibbonContextMenu object, when i click on the right button with the mouse on one (selected) or more files from the attachment list, i want to be able to get just the selected one (one or more).
i sow some solution in VB or C# - how to chatc AttachmentSelection object. but i can not see how to translate it to Delphi.
i tried something like :
Var
AttachmentSelection: OleVariant;
ExploreeSelection: OleVariant;
ISelection: Selection;
i,j: integer;
IExpl: _Explorer;
VIntf: OleVariant;
Intf: Outlook2000._MailItem;
begin
AttachmentSelection := OleVariant(RibbonControl.Context);
ShowMessage(IntToStr(AttachmentSelection.Class));
if AttachmentSelection.Class = 169 then // olAttachmentSelection = 169
begin
for i := 1 to AttachmentSelection.Count do begin
ShowMessage(AttachmentSelection.Item(i).FileName);
end;
end
else
if AttachmentSelection.Class = 34 then
begin // olExplorer = 34
IExpl := OutlookApp.ActiveExplorer();
ISelection := nil;
if Assigned(IExpl) then
try
try
ISelection := IExpl.Selection;
except
// "The Explorer has been closed and cannot be used for further operations"
ISelection := nil;
end;
finally
IExpl := nil;
end;
if Assigned(ISelection) then
Try
for i := 1 to ISelection.Count do
begin
//ShowMessage(ISelection.item(i));
VIntf := ISelection.Item(i);
ShowMessage(IntToStr(VIntf.Class));
if ((VIntf.Class = olAttachment) or (VIntf.Class = olAttachments)) Then
begin
ShowMessage('olAttachment or olAttachments');
end
else
if (VIntf.Class = olMail) Then
begin
ShowMessage('olMail');
IDispatch(Intf) := Self.OutlookApp.ActiveExplorer.Selection.Item(i);
for j := 1 to Intf.Attachments.count do
begin // this is not the selected list. it just "ALL THE LIST"
end;
end;
VIntf := Unassigned;
end;
finally
ISelection := nil;
end;
end
else
begin
//ShowMessage('Not an AttachmentSelection');
end;
end;
but this give me the all list and i can't find any property of "selected" in the attachment item. i look at IMIBO (extended mapi) and didn't find any solution there also.
did some one able to get this list?
in C# the code is : From https://www.add-in-express.com/forum/read.php?FID=5&TID=13763
object context = control.Context;
if (context is Outlook._Explorer)
{
MessageBox.Show("EXPLORER");
Outlook._Explorer window = context as Outlook._Explorer;
MessageBox.Show("Count: " + window.AttachmentSelection.Count);
GetAttachmentsInfo(item, window.AttachmentSelection);
Marshal.ReleaseComObject(window.AttachmentSelection);
}
else if (context is Outlook._Inspector)
{
MessageBox.Show("INSPECTOR");
Outlook._Inspector window = context as Outlook._Inspector;
MessageBox.Show("Count: " + window.AttachmentSelection.Count);
GetAttachmentsInfo(item, window.AttachmentSelection);
Marshal.ReleaseComObject(window.AttachmentSelection);
}
else if (context is Outlook._AttachmentSelection)
{
MessageBox.Show("ATTACHMENTSELECTION");
Outlook._AttachmentSelection attSelection = context as Outlook._AttachmentSelection;
MessageBox.Show("Count: " + attSelection.Count);
GetAttachmentsInfo(item, attSelection);
Marshal.ReleaseComObject(attSelection);
}
thanks.