no example or support in DELPHI?

Add-in Express™ Support Service
That's what is more important than anything else

no example or support in DELPHI?
 
Yossi Mazal Tov




Posts: 34
Joined: 2013-02-04
i see you have good example in C# or VB

how can i translate this to DELPHI
-- i am poor in COM OBJECT Developing, losing to much time to understend some thing i have to deal in 1 i 3-5 years

private void adxRibbonButton1_OnClick(object sender, IRibbonControl control, bool pressed)
{
int result = 0;
object context = control.Context;

if (context is Outlook._Explorer)
{
Outlook._Explorer window = context as Outlook._Explorer;
Outlook._AttachmentSelection attSelection = window.AttachmentSelection;
result = attSelection.Count;
Marshal.ReleaseComObject(attSelection);
}
else if (context is Outlook._Inspector)
{
Outlook._Inspector window = context as Outlook._Inspector;
Outlook._AttachmentSelection attSelection = window.AttachmentSelection;
result = attSelection.Count;
Marshal.ReleaseComObject(attSelection);
}
else if (context is Outlook._AttachmentSelection)
{
Outlook._AttachmentSelection attSelection = context as Outlook._AttachmentSelection;
result = attSelection.Count;
Marshal.ReleaseComObject(attSelection);
}
else
{
result = -1;
}

if (context == null)
{
result = int.MinValue;
}
else
{
Marshal.ReleaseComObject(context);
}
MessageBox.Show("Selected attachment count = " + result.ToString());
}
Posted 14 Aug, 2018 16:49:21 Top
Yossi Mazal Tov




Posts: 34
Joined: 2013-02-04
i check the HELP PDF that supplied with the last version of the VCL

the word "attachment" is exists just one time and only with "NOT"....remark.

page 79/119

For a Ribbon control shown on a Ribbon tab, the context represents the window in which the Ribbon control is shown: Excel.Window, Word.Window, PowerPoint.DocumentWindow, Outlook.Inspector, Outlook.Explorer, etc. For a Ribbon control shown in a Ribbon context menu the context object may not be a window e.g. Outlook.Selection, Outlook.AttachmentSelection, etc. When debugging the add-in we recommend that you find the actual type name behind the context object by using IDispatch.GetTypeInfo() and then ITypeInfo.GetDocumentation().

why there are tons of example in c#,vb but none in DELPHI?

i'm not rely wont to be COM/OUTLOOK developrs.
i just wont to add save capability from outlook to my DMS.
1. save all mail - button on the explorer - work.
2. save one or more attachment - work until 2010, not in 2013+
i need the selected attach file.

that all.
95% of all how create ADDIN with yours good components need this.
you maybe have good sample in c#,vb...
the last sample in delphi, was writen long time ago.
i develop in VCL , dont no any other lanuage ....
maybe some one can help...
Posted 15 Aug, 2018 03:29:03 Top
Andrei Smolin


Add-in Express team


Posts: 15583
Joined: 2006-05-11
Hello Yossi,

With Add-in Express for .NET and Add-in Express for VCL, you deal with the [almost the] same components providing the same set of properties and events. I assume you do not need any code demonstrating how a component works.

Outlook is COM based and you do know this. Talking about the number of examples in other programming languages is fruitless. You should be able to read code written in any other programming language. Even if you cannot understand it 100%, you'll be able to grab the main idea of what the component(s) provides.

Also, I strongly suggest that you read section Office Ribbon Components, see the PDF file in the folder {Add-in Express}\Docs on your development PC. Putting aside all general things, it explains how the Ribbon works. This is the information that you need at this stage.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 15 Aug, 2018 09:52:10 Top
Yossi Mazal Tov




Posts: 34
Joined: 2013-02-04
irely dont understend, u can put tousend of code in c# but no one in DELPHI.
i dont undrestend C# or read the type and get them in DEPHI
what is so problamitcly to trunslate this code of yours to delphi :

if u sale the VCL components, why dont u shiped it with examples.
i dont rely car or want to read this or this section. just simple example will do.

after i will fix this problem - the next time will be when outlook 2018/19/20 will not work right.

private void adxRibbonButton1_OnClick(object sender, IRibbonControl control, bool pressed) {
int result = 0;
object context = control.Context;

if (context is Outlook._Explorer)
{
Outlook._Explorer window = context as Outlook._Explorer;
Outlook._AttachmentSelection attSelection = window.AttachmentSelection;
result = attSelection.Count;
Marshal.ReleaseComObject(attSelection);
}
else if (context is Outlook._Inspector)
{
Outlook._Inspector window = context as Outlook._Inspector;
Outlook._AttachmentSelection attSelection = window.AttachmentSelection;
result = attSelection.Count;
Marshal.ReleaseComObject(attSelection);
}
else if (context is Outlook._AttachmentSelection)
{
Outlook._AttachmentSelection attSelection = context as Outlook._AttachmentSelection;
result = attSelection.Count;
Marshal.ReleaseComObject(attSelection);
}
else
{
result = -1;
}

if (context == null)
{
result = int.MinValue;
}
else
{
Marshal.ReleaseComObject(context);
}
MessageBox.Show("Selected attachment count = " + result.ToString()); }
Posted 15 Aug, 2018 10:57:11 Top
Yossi Mazal Tov




Posts: 34
Joined: 2013-02-04
i will pay you. name the price.

on outlook 2010,2013,2016

1. button on the main panel - click will save the message / messages the user select
for each messahe - write xml/ini/txt that give the email entry no + save as *.msg

2. on the attachment list - the user will see "button" that with the button he can save the selcted atachment/atachments file/s for each selected item, save the item and call"prog aa" for all selected files

3. on the mail list the user can see the "save message" to XXXXX.

i will finish the rest.

thanks
Yossi Mazal-Tov
Posted 15 Aug, 2018 11:10:30 Top
Yossi Mazal Tov




Posts: 34
Joined: 2013-02-04
just in DELPHI
no c#
no VB
no any other language
Posted 15 Aug, 2018 11:11:49 Top
Yossi Mazal Tov




Posts: 34
Joined: 2013-02-04
i so u have written nice "Global Bank" in DELPHI.
can you share it with DELPHI developers?
Posted 15 Aug, 2018 12:54:56 Top
Yossi Mazal Tov




Posts: 34
Joined: 2013-02-04
i checl all the samples in DELPHI sample lib
all from 2008-2009, very old, dont you upgade them?

dont you have someone how now DELPHI?

if i buy (and i did),
Ehlib, full of samples
LMD, full of samples
QuickPdf, full of samples
SmWord, full of samples
AlphaControl, full of samples
IMIBO, full of samples
QuickReport, full of samples
.....

but it seem you can not provide Samples in DELPHI, Why?
Posted 16 Aug, 2018 02:21:01 Top
Andrei Smolin


Add-in Express team


Posts: 15583
Joined: 2006-05-11
Hello Yossi,

The Office object models are HUGE. We don't have resources to create and maintain examples for every possible usage.

Let me start with explaining how Outlook and Ribbons work and how (and where) you can insert your code in order to get the list of attachments selected by the user.

Put a TAdxRibbonContextMenu onto the add-in module, specify the component's Ribbons property and, in the ContextMenuName property, select the names of the context menus that you need to customize. Then you add a Ribbon button to the Controls property of the component. The final step is to register the project and make sure that you have your button shown in the context menus required. Once this done, you can start to write code.

Selected attachments are listed in the AttachmentSelection object; see https://msdn.microsoft.com/en-us/VBA/outlook-vba/articles/attachmentselection-object-outlook. You get the AttachmentSelection object as the context of a Ribbon control's event; the Ribbon control (e.g. the ribbon button you added on the previous step) is located in the context menu that you open by right-clicking an attachment (selected attachments). On retrieving the context, please see section Determining a Ribbon Control's Context, see the PDF file in the folder {Add-in Express}\Docs on your development PC.

With a Ribbon button you have two events: Click and PropertyChanging. They let you implement two main scenarios: 1) getting the list of attachment when your button is clicked, and 2) modify the Ribbon button's properties (Visible, Enabled, Caption etc.) depending on the attachment(s) selected. In both scenarios, you get the context object, and, if it is of the AttachmentSelection type, use it to fulfill your needs.

More on the PropertyChanging event. It fires whenever Office needs to retrieve a property of your Ribbon button. That is, it fires multiple times: to get the Visible, Enabled, Caption, Size, etc. properties of the Ribbon button; see the PropertyType parameter of the event procedure. In the code of the PropertyChanging event handler, you do not modify any property of the Ribbon component for which the PropertyChanging event is invoked. Instead, you use the PropertyChanging event to dynamically supply Office with this or that value of the requested property depending on the context and business rules; to pass Office the value produced by your code, set the Value parameter of the event procedure.

A hint. As the description above suggests, you can get your control hidden from the user and still learn the context.

Hope this helps.

Also note that we can create an example on request if you have an active Premium subscription; please contact our sales if you need such a subscription.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 16 Aug, 2018 05:22:17 Top
Nelson Fernandez




Posts: 9
Joined: 2018-02-07
I have done this within the message (not ribbon). It is frustrating to not see working code samples but these are essentially wrappers for the office products so how to use them is microsofts design. That said I can share a couple of functions that help me. You may need to edit for your scenario. The following is how I get the mailitem:


m_MailItem := DM.GetMailItem(GetParentInterface);

// save MSG
m_MailItem.SaveAs(sFilename, olMSG);

// save Attachments
for iIDX := 1 to m_MailItem.Attachments.Count do begin
        att := m_MailItem.Attachments.Item(iIdx);
        sExt := ExtractFileExt(att.FileName);
        sFilename := 'myfile.'+ sExt;
        att.SaveAsFile(sFilename);
end;



function TolfLPInfo.GetParentInterface: IDispatch;
var
    root, Handle: Hwnd;
    i: integer;
    c: cardinal;
    IWindow: IOleWindow;
    IExplorer: _Explorer;
    IInspector: _Inspector;
begin
    //
    FIsInspector := False;
    root := Windows.GetAncestor(self.Handle, GA_ROOT);

    for i := 1 to adxcoBMCOutlook.GetOutlookApp.Explorers.Count do
    begin

        IExplorer := adxcoBMCOutlook.GetOutlookApp.Explorers.Item(i);
        IExplorer.QueryInterface(IOleWindow, IWindow);
        IWindow.GetWindow(Handle);

        if HandleToString(Handle) = HandleToString(root) then
        begin
            FIsInspector := False;
            Result := IExplorer;
        end;
    end;

    for i := 1 to adxcoBMCOutlook.GetOutlookApp.Inspectors.Count do
    begin

        IInspector := adxcoBMCOutlook.GetOutlookApp.Inspectors.Item(i);
        IInspector.QueryInterface(IOleWindow, IWindow);
        IWindow.GetWindow(Handle);

        if HandleToString(Handle) = HandleToString(root) then
        begin
            FIsInspector := True;
            Result := IInspector;
        end;
    end;

    FParentInterface := Result;
end;


function TDM.GetMailItem(const ExplorerOrInspector: IDispatch): _MailItem;
var
    IExplorer: _Explorer;
    ISelection: Selection;
    IInspector: _Inspector;
    miRes: _MailItem;
    item: IDispatch;
    IMail: MailItem;
begin
    if (ExplorerOrInspector <> nil) then
    begin
        ExplorerOrInspector.QueryInterface(IID__Explorer, IExplorer);
        if Assigned(IExplorer) then
            try
                try
                    ISelection := IExplorer.Selection;
                except
                    ISelection := nil;
                    // skip an exception generated by Outlook when some folders are selected
                end;
                if Assigned(ISelection) then
                    try
                        if ISelection.Count > 0 then begin
                            item :=  ISelection.Item(1);
                            item.QueryInterface(IID__MailItem, IMail);

                        end;
                    finally
                        ISelection := nil;
                    end;
            finally
                IExplorer := nil;
            end
        else
        begin
            ExplorerOrInspector.QueryInterface(IID__Inspector, IInspector);
            if Assigned(IInspector) then begin
                try
                    item := IInspector.CurrentItem;
                    item.QueryInterface(IID__MailItem, IMail);
                finally
                    IInspector := nil;
                end;
            end;
        end;
    end;


    Result := IMAil;

end;

function HandleToString(aHandle: Hwnd): string;
begin
    Result := cardinal(aHandle).ToString;
end;



Hope that helps a little.
Posted 20 Sep, 2018 12:12:37 Top