I'm navigating using the webbrowser in the end i'm getting to webbrowser4 document completed event.
At this point i have in the webbrowser already the page to add a message. I also can give the message a title.
Now i want to add to this message attached image/s. The problem is how to attach the images.
void webBrowser4_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (e.Url.AbsoluteUri != webBrowser4.Url.AbsoluteUri)
{
return;
}
HtmlElementCollection items = webBrowser4.Document.GetElementsByTagName("div");
foreach (HtmlElement item in items)
{
if (item.GetAttribute("className") == "elements")
{
webBrowser4.Document.GetElementById("ctl00_RightMainContent_txt_subject").InnerText = "Hello world";
}
}
HtmlElementCollection classButton = webBrowser4.Document.All;
foreach (HtmlElement element in classButton)
{
if (element.GetAttribute("className") == "addImg")
{
element.InvokeMember("click");
}
}
HtmlElementCollection classButton1 = webBrowser4.Document.All;
foreach (HtmlElement element in classButton1)
{
if (element.GetAttribute("className") == "uplFileDrgDrp")
{
element.InvokeMember("click");
}
}
}
First i'm adding a title to the message Hello World
Then i click on the button addImg
The last part should attach now the images. After i click addImg i can click on another button and browse to images i want to attach from my hard disk or i can drag and drop images to this addImg window. In any case i want to add this images without browsing or even without drag and drop them but i can't figure out how.
This is a screenshot of the website after clicked to add a new message:
screenshot[
^]
My question is how can i attach the images i want automatic. Let's say i'm GetFiles and i have array of images and now i want to attach them to the message.
This is the whole add message page view-source link
When the window to drag and drop images is opened and i'm doing inspect element i see:
[
^]
Maybe somehow to make that it will drag and drop automatic the images files from array of images. Not sure how to do it at all.
What I have tried:
What i tried is mentioned in the question you can see it here more clear here:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/cc81eaf5-8f6b-479e-85c8-9cadd259ee3d/how-can-i-attach-automatic-images-to-container-in-a-web-page-using-webbrowser-control-?forum=csharpgeneral