Thread

Index > Scribe > Scripting query: accessing contact info
Author/Date Scripting query: accessing contact info
Scott
24/12/2017 12:21am
I'm writing a script to create a context menu on a mail item to pop open the web page from the Mail.From.Contact details. I've encountered two problems:
- How do I get the details such as "webpage" from the contact details? I didn't see any of these fields in the DOM.
- How do I launch a browser with this webpage? I.e., how do I execute a process from a script file?
fret
24/12/2017 9:29am
Ah yes, so when the script retrieves the 'Contact' object it's actually the wrong one, one from the storage back end instead of the UI level. So I've changed the API and got the right object returned form .Contact and .Groups fields of the 'From' object.

As for executing a process you should look at 'System' scripting library function.
Scott
12/01/2018 11:44pm
Ah yes, so when the script retrieves the 'Contact' object it's actually the wrong one, one from the storage back end instead of the UI level. So I've changed the API and got the right object returned form .Contact and .Groups fields of the 'From' object.
I don't see any webpage or site information in the latest DOM. Which member should I be looking at?


As for executing a process you should look at 'System' scripting library function. I use the following code and it doesn't open the browser:
  System("C:\Program Files (x86)\Pale Moon\palemoon.exe", u);
where u has been set to the url. If I copy this into a command line, it works as expected.
fret
13/01/2018 9:39am
I don't see any webpage or site information in the latest DOM. Which member should I be looking at?
See the 'Dom.txt' in the scripting sub-folder of your install. It's always auto-generated from the C++ source and fully up to date.

I use the following code and it doesn't open the browser:
Oh you have to quote the directory separators like this:
 System("C:\\Program Files (x86)\\Pale Moon\\palemoon.exe", u);
Scott
14/01/2018 12:57am
I've got the browser opening now.
Using Thing.Contact, I'm getting access to the Contact structure from ScribeContact.cpp:708. However, I don't see any webpage or contact information in this structure.
ALL
27/01/2018 6:23pm
Could you help with(give) the script that to open message-body by 'view in Some another browser'.
And set path to Browser f.ex.:
System("C:\Program Files (x86)\Pale Moon\palemoon.exe", u);
fret
28/01/2018 4:37pm
Scott: However, I don't see any webpage or contact information in this structure..
Oh that's because the contact was implemented a bit differently to all the other types. So the python script fails to scoop up the field names. However I'm just realizing that some of the field names have spaces in them which wont work for scripting. So I'm going to have to re-factor a bunch of code before it'll work properly. Sorry.
fret
28/01/2018 4:41pm
ALL: Could you help with(give) the script that to open message-body by 'view in Some another browser'.
So in looking at this one main problem presented itself. There is currently no way to get system path info from scripts. Particularly the "temp" path that would be suitable for a temporary HTML file. So I've added some new functions (e.g. GetScribeTempPath and JoinPath) that you could use like this:

function OpenInBrowser(Application, Thing, CallbackId)
{
    if (Thing.Type != 0xAAFF0001)
    {
        Print("Error: Not an email: " + Thing.Type + "\n");
        return false;
    }

    ScribeTmp = GetScribeTempPath();
    OutPath = JoinPath(ScribeTmp, "_email.html");
    WriteTextFile(OutPath, Thing.BodyAsHtml);

    Execute("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", OutPath);

    return true;
}

function AddMenus(App, Thing, Menu)
{
    Menu.AppendSeparator();
    GMenuAddItem(Menu, -1, "Open In Browser", -1, "OpenInBrowser", 2001);
}

function Main(App)
{
    if (!AddCallback("OnThingContextMenu", "AddMenus"))
        MsgBox(App, "Couldn't add AddMenus");

    return 1;
}
Then to use this you would right click on the email, and select "Open In Browser". Obviously you can change the browser to whatever you want. In my case I was testing with Firefox.
ALL
29/01/2018 8:47pm
Thanks,
It is working well. :)
Reply