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 am creating a plugIn for Internet Explorer using C# i added three buttons in that plugIn.But I want to display that plugIn when we open Gmail or yahoomail then only.So how can we do this??
i am writing like this..
private void IEModule_OnConnect(object sender, int threadId)
{
//What the Code i have to write here...??
//Can we write some javascript code here??If yes can you please tell me how..

}
Please help me in this area..I am really frustating...Its very urgent...Thanks in Advance..

Thanks
Rajesh
Posted 17 Aug, 2011 14:42:34 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Rajesh.

Of course, you can't write the javascript code in C# files. I would advise you to disable the buttons on your toolbar when the user navigates to any websites except for Gmail and yahoomail. To control the URL location you can use the DocumentComplete event.
Posted 18 Aug, 2011 07:12:43 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
Thank you very much for your reply.But can you send me the code how to write it please i,e how to get the URL and check...


And 1 More Question please.I have one requirement.In the Add In express For Internet Explorer i created a pugIn.And in that plugIn i put 1 button(SendButton).And i opened Gmail page(www.gmail.com) Compose mail page.So whatever i enter To,CC,Bcc,Subject,Body etc.... and click the PlugIn button(send) than mail should go.So how can i achieve this please help me with the Code.These are very important...Thanks in Advance...

Thanks and Regards
Rajesh kumar jena
Posted 22 Aug, 2011 09:41:08 Top
Sergey Grischenko


Add-in Express team


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

To get the url in DocumentComplete event handler you can use the 'url' parameter of the event handler.

Does the new email webpage have the Send button? If so, you can use the 'getElementById' method of the document to search for the Send button and then call the 'Click' method of the button element to perform the action.
Posted 22 Aug, 2011 10:47:27 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
That is not the new Email web page.That is the gmail page only(www.gmail.com)We are not creating any UI.I am getting the Button click.But how can i take the Gmail(Composemail) value i,e whatever i enter To,CC,Subject etc...from the Gmail page.That value how can i get my page.So in this case how can i take the value.Please let me know if the question is not clear??


And 1 more thing this is C# desktop application(Project).So in the .CS file how can i write javascript??


Thanks
Rajesh kumar jena
Posted 22 Aug, 2011 11:42:40 Top
Sergey Grischenko


Add-in Express team


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

Here is the code to access the 'To' field. You can use the same code to access 'Cc', 'Bcc' and so on.
object[] list = AddinExpress.IE.ADXIEHelper.GetHTMLElementsByName(this.HTMLDocument, "to");
if (list.Length > 0)
{
if (list[0] is mshtml.IHTMLTextAreaElement)
MessageBox.Show(this, (list[0] as mshtml.IHTMLTextAreaElement).value);
else if (list[0] is mshtml.IHTMLInputTextElement)
MessageBox.Show(this, (list[0] as mshtml.IHTMLInputTextElement).value);
}

And 1 more thing this is C# desktop application(Project).So in the .CS file how can i write javascript??

C# compiler doesn't support javascript. You need to use the MSHTML object model to write the same code but in C#.
Posted 23 Aug, 2011 06:10:01 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
Thanks for your help.It works Great.I have one more doubt.Here i am getting the to,cc,bcc etc....But how can i get the attachment??Can you please help me the attachment Code? I will be thankful...

Thanks once again...

And i am not getting the Body also.I am writing the code like below.
object[] listBody = AddinExpress.IE.ADXIEHelper.GetHTMLElementsByName(this.HTMLDocument, "body");
if (listBody.Length > 0)
{
if (listBody[0] is mshtml.IHTMLTextAreaElement)
MessageBox.Show(this, (listBody[0] as mshtml.IHTMLTextAreaElement).value);
else if (listBody[0] is mshtml.IHTMLInputTextElement)
MessageBox.Show(this, (listBody[0] as mshtml.IHTMLInputTextElement).value);
}

So here i am getting null.How can i get the body ??
Thanks you very much.


Thanks
Rajesh kumar jena

Thanks and regards
Rajesh kumar jena
Posted 23 Aug, 2011 07:06:12 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Rajesh, you can use the 'View->Source' option of IE to learn names of all HTML elements on the opened webpage.
Posted 23 Aug, 2011 10:11:32 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
Thank you for yoyr Reply. I am extremely sorry that i didnot find the name of the Compose mail Body.They are using some Iframe and if i get ID also its some conversion issue is there.Please help me..

Thanks
Rajesh kumar jena
Posted 23 Aug, 2011 12:25:28 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Rajesh, I don't quite understand the issue. Please clarify.
Posted 24 Aug, 2011 05:59:40 Top