How to use Javascript using Addins

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

How to use Javascript using Addins
 
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
I have one more Problem, I have created a add-in for Outlook and when I send a mail
using it every time getting this warning.

A program is trying to send an e-mail message on your behalf. If this is unexpected, click Deny and verify your antivirus software is up-to-date.

Could you please tell me how to get rid of this.

Thanks in Advance
Posted 25 Aug, 2011 09:36:29 Top
Sergey Grischenko


Add-in Express team


Posts: 7228
Joined: 2004-07-05
Hi Raju,

What the code do you use to send an email?
Posted 25 Aug, 2011 10:54:24 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
I am using the below code.
public int SendMail()
{
//Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
Outlook._MailItem oMailItem = (Outlook.MailItem)nspace.Application.ActiveInspector().CurrentItem;

//If not valid emailid.
if (oMailItem.To != null)
{

string str = oMailItem.To;
string str1 = oMailItem.CC;
string str2 = oMailItem.BCC;
//int aa = item.To.Count();
str = str.Trim();
string[] arr,arr1,arr2;
//we can assign this dynamically using comma in To field.
string ToAddress = "";
string CCAddress = "";
string BCCAddress = "";
//ArrayList arrList = new ArrayList();

//If multiple emailid in l
if (str.Contains(";"))
{
arr = new string[200];

arr = str.Split(';');
for (int i = 0; i < arr.Count(); i++)
{
ToAddress += arr[i] + ".xyz.com;";
}
//Remove last char form string.
string temp = ToAddress.Remove(ToAddress.Length - 1, 1);
ToAddress = temp;


}
else
{
ToAddress = oMailItem.To + ".xyz.com";
}
if (oMailItem.CC != null)
{
//If multiple emailid in CC
if (str1.Contains(";"))
{
arr1 = new string[200];

arr1 = str.Split(';');
for (int i = 0; i < arr1.Count(); i++)
{
CCAddress += arr1[i] + ".xyz.com;";
}
//Remove last char form string.
string temp = CCAddress.Remove(CCAddress.Length - 1, 1);
CCAddress = temp;


}
else
{
CCAddress = oMailItem.CC + ".xyz.com";
}
}



oMailItem.CC = CCAddress.ToString();
//oMailItem.BCC = BCCAddress.ToString();
oMailItem.Subject = oMailItem.Subject;
oMailItem.Body = oMailItem.Body;
oMailItem.To = ToAddress.ToString();

oMailItem.Save();

try
{

oMailItem.Save();
oMailItem.Send();

return 0;
}
catch (System.Exception)
{

return 2;
}
}

else
{
return 1;
}
}

Thanks and regards
Raju
Posted 26 Aug, 2011 14:04:11 Top
Sergey Grischenko


Add-in Express team


Posts: 7228
Joined: 2004-07-05
Hi Raju.

Do you create an Outlook instance via OLE Automation in IE add-on? If so, you need to use the 'Outlook Security Manager' component to disable security warnings.
http://www.add-in-express.com/outlook-security/
Posted 29 Aug, 2011 10:53:48 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
Sorry for Responding you late...I am still stuck from that Day in Gmail(Compose mail page)i have to take out the To,Cc,Bcc etc....I am getting the value like this...

object[] list = AddinExpress.IE.ADXIEHelper.GetHTMLElementsByName(this.HTMLDocument, "to");
object[] listCc = AddinExpress.IE.ADXIEHelper.GetHTMLElementsByName(this.HTMLDocument, "cc");

etc.....

But i am not able to get the Body...Can you please tell me how to get the Body even though i tried from right Click->Page View Source....Please help me..

Thanks in Advance..

Thanks and Regards
Rajesh kumar jena
Posted 07 Sep, 2011 07:01:42 Top
Sergey Grischenko


Add-in Express team


Posts: 7228
Joined: 2004-07-05
Hi Raju.

Please try the code below:

object[] frames = AddinExpress.IE.ADXIEHelper.GetFrames(this.HTMLDocumentObj);
foreach (mshtml.IHTMLWindow2 elem in frames)
{
mshtml.IHTMLDocument2 doc =
AddinExpress.IE.ADXIEHelper.GetFrameDocument(elem) as mshtml.IHTMLDocument2;

object[] all = AddinExpress.IE.ADXIEHelper.GetHTMLElementsByTagName(doc, "body");
foreach (mshtml.HTMLBodyClass body in all)
{
if (body.className != null && body.className == "editable LW-yrriRe")
MessageBox.Show(this, body.innerText);
}
}
Posted 07 Sep, 2011 16:29:28 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
Thanks dude..Its working Great....


Thanks once Again..
Rajesh kumar jena
Posted 08 Sep, 2011 08:44:20 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
I have one more doubt here.I am creating plugins for IE for gmail,yahomail hotmail mac mail etc....

For gmail i am writing the below code its working...
object[] list = AddinExpress.IE.ADXIEHelper.GetHTMLElementsByName(this.HTMLDocument, "to");
object[] listCc = AddinExpress.IE.ADXIEHelper.GetHTMLElementsByName(this.HTMLDocument, "cc");

etc...

But the same code i am writing for yahoomail compose mail and from page->viewsource compose mail i found 'To' as 'to-field' so i wrote like this..
object[] list = AddinExpress.IE.ADXIEHelper.GetHTMLElementsByName(this.HTMLDocument,"to-field");

But this one not working....This value is null showing..

Please help me again...Thanks

Thanks
Posted 08 Sep, 2011 10:35:40 Top
Sergey Grischenko


Add-in Express team


Posts: 7228
Joined: 2004-07-05
Hi Raju,

There is another way to determine the correct name/id of HTML elements.
You need to create a new context menu item and add a breakpoint to the OnClickEx event handler of the item. Then you can use the QuickWatch dialog of the debugger to see all properties of the HTML element set in the e.HTMLElement property of the ADXIEMenuItemClickEventArgs object.
Posted 08 Sep, 2011 11:01:49 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hey Sergey,
Thank you for your reply.But i am poor in this area.Can you please sens me the codes how to do this?

Thanks


Raju
Posted 08 Sep, 2011 11:50:10 Top