wxnko
Posts: 2
Joined: 2020-09-22
|
I started with this in outlook.
https://www.add-in-express.com/creating-addins-blog/2014/11/26/access-outlook-html-javascript-addins/
I changed form to rightdock. Now I want to use this kind of method inside InspectorBrowser class to pass accounts data to HTML
private void EnumerateAccounts()
{
//The problem is here
Outlook.Accounts accounts = OutlookHost.Session.Accounts;
foreach (Outlook.Account account in accounts)
{
try
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("Account: " + account.DisplayName);
if (string.IsNullOrEmpty(account.SmtpAddress)
|| string.IsNullOrEmpty(account.UserName))
{
Outlook.AddressEntry oAE =
account.CurrentUser.AddressEntry
as Outlook.AddressEntry;
if (oAE.Type == "EX")
{
Outlook.ExchangeUser oEU =
oAE.GetExchangeUser()
as Outlook.ExchangeUser;
sb.AppendLine("UserName: " +
oEU.Name);
sb.AppendLine("SMTP: " +
oEU.PrimarySmtpAddress);
sb.AppendLine("Exchange Server: " +
account.ExchangeMailboxServerName);
sb.AppendLine("Exchange Server Version: " +
account.ExchangeMailboxServerVersion);
}
else
{
sb.AppendLine("UserName: " +
oAE.Name);
sb.AppendLine("SMTP: " +
oAE.Address);
}
}
else
{
sb.AppendLine("UserName: " +
account.UserName);
sb.AppendLine("SMTP: " +
account.SmtpAddress);
if(account.AccountType ==
Outlook.OlAccountType.olExchange)
{
sb.AppendLine("Exchange Server: " +
account.ExchangeMailboxServerName);
sb.AppendLine("Exchange Server Version: " +
account.ExchangeMailboxServerVersion);
}
}
if(account.DeliveryStore !=null)
{
sb.AppendLine("Delivery Store: " +
account.DeliveryStore.DisplayName);
}
sb.AppendLine("---------------------------------");
Debug.Write(sb.ToString());
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
How can I get access to OutlookHost to get session?
In main addin class I would use code below but in ADXOlForm HostApplication is not defined.
public Outlook._Application OutlookHost()
{
return (HostApplication as Outlook._Application);
} |
|
wxnko
Posts: 2
Joined: 2020-09-22
|
The solution is here:
public Outlook._Application OutlookHost()
{
return (AddinExpress.MSO.ADXAddinModule.CurrentInstance.HostApplication as Outlook._Application);
}
I don't know why code below passes empty object to JS that's why I hadn't used it.
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
var d = webBrowser.Document.DomDocument as mshtml.HTMLDocument;
try
{
dynamic window = d.parentWindow;
var windowEx = (IExpando)window;
PropertyInfo p = windowEx.AddProperty("bhoModule");
p.SetValue(windowEx, AddinExpress.MSO.ADXAddinModule.CurrentInstance, null);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("error adding ie script: " + ex.Message);
}
} |
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
|