|
i want to get noticed that some mail have been recieved in my outlook n if it is from a desired sender then i want my code to code some task...i want to do it in C#....can n e budy will help me.....thanx.
|
|
|
|
|
What have you tried ? What have you found out ? Have you installed the Microsoft tools for office ? What do the docs say you can and cannot do ? I doubt you can get a message from outlook, I expect you'd have to poll it at regular intervals.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Gotcha again - this person asked the same question 3 days ago and got some good references, where is that bloody pop up......
|
|
|
|
|
consentrate buddy....i have asked earlier about sending the mail to outlook inbox of anybuddy....now i have the exactly opposite question....that is how do i get informed that some mail have arrived in my outlook inbox!!!! make it clear!!!!
|
|
|
|
|
Hi,
I host a WebBrowser control in a WinForm. When the user clicks a button I call Navigate(url) on the control, but it's not 100% reliable. Sometimes the control will navigate to the page, but sometimes it won't, for exactly the same URL. Has anyone seen something similar?
thanx
|
|
|
|
|
I would imagine this means that there's events being fired by the control and sometimes you're in sync with them, and some times not. You should look at what state change events the control fires and see if you can detect a pattern between those and when your code works or not. The control should work just fine.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I'm not sure what you mean. I call webControl1.Navigate("www.amazon.com"); on every button click. Sometimes it works, sometimes it doesn't.
|
|
|
|
|
Well, the control works, so one assumes that it must sometimes be in a state where you have to wait before you navigate.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi
I have a method that takes in data from XML, puts it temporarily into a dataset, where I then add to a List Object. This bits ok, but where I am falling over, is where there is more than one item of data in an XML node. In my code I am using foreach to iterate through each node, and this is working because I am seeing loop through each element in the node. However, when I am adding it to the List Object, it is only adding the last node to the list rather than every element.
The structure of the xml is that the first two nodes can only have one set of data, but the last two can have one to many, and this is where it goes wrong. I did try mylist.add(adddata) at the end of the loop, but what happened was that the last item was added but repeated x number of times for the number of items in the data.
Can anyone show me a good answer to this problem?
Thanks
|
|
|
|
|
It's impossible to say what's wrong without seeing the code that is doing this processing.
|
|
|
|
|
Hi
I know this sounds an odd question, but there is logic to my question. In my application, there will be a method that will call a method in a web service. However, and this is the logic bit, I just don't want to call the method and hope for the best, I want to check to see if the web service is running first. If it is, then call the method, else return a message to the user to say it is not running.
Does anyone show me a neat way to check to see if a web service is running or not?
Thanks
|
|
|
|
|
The only way to tell is to call it. Simple as that. There is no cool little trick to find out.
|
|
|
|
|
If you wrote the web service you could add an IsRunning method...
But your best bet is to just call the desired method.
|
|
|
|
|
PIEBALDconsult wrote: If you wrote the web service you could add an IsRunning method...
Which would timeout just like calling the original method anyway. So what's the difference? Adding a second webservice that would tell you the status of the first one, which it could only do by calling it itself... ...and so on, and such like...
|
|
|
|
|
|
I'm trying to learn and work on azure table storage. The code works perfectly in my local. When I configure to the azure and still trying to work with my local (not using publish), I'm getting an exception.
public bool DoesTableExist(string tableName)
{
ParameterValidator.CheckStringParameter(tableName, false, "tableName");
bool tableExists = false;
RetryPolicy(() =>
{
try
{
DataServiceContext svc = GetDataServiceContext();
svc.MergeOption = MergeOption.NoTracking;
IEnumerable<TableStorageTable> query = from t in svc.CreateQuery<TableStorageTable>(TableStorageConstants.TablesName)
where t.TableName == tableName
select t;
tableExists = false;
try
{
// the query contains the whole primary key
// thus, if the query succeeds we can be sure that the table exists
(query as DataServiceQuery<tablestoragetable>).Execute(); tableExists = true;
}
catch (DataServiceQueryException e)
{
HttpStatusCode s;
if (TableStorageHelpers.EvaluateException(e, out s) && s == HttpStatusCode.NotFound)
{
tableExists = false;
}
else
{
throw;
}
}
catch (NullReferenceException ne)
{
//This is a workaround for bug in DataServiceQuery<T>.Execute. It throws a
//NullReferenceException instead of a DataServiceRequestException when it
//cannot connect to the the server. This workaround will be removed when
//the fix for this bug is released.
throw new DataServiceRequestException("Unable to connect to server.", ne);
}
}
catch (InvalidOperationException e)
{
HttpStatusCode status;
if (TableStorageHelpers.CanBeRetried(e, out status))
{
throw new TableRetryWrapperException(e);
}
throw;
}
});
return tableExists;
}
when it executes the (query as DataServiceQuery<TableStorageTable>).Execute() it has to fail and come to DataServiceQueryException and make tableExists = false and return with the same to create the table. Instead the code goes to the catch (NullReferenceException ne)and says unable to connect to the server. can someone help me onthis please.Thanks.
|
|
|
|
|
Hello Everyone, Im an extremely new programmer and this is the first time im trying out something like this.
I need to upload a XSD file and a XML file, then I need to check whether the XML file is valid comparing to the XSD file. These files are on my desktop.
Here is my code so far, but I am missing a lot of things. Any help will be great.
Button1: This is my validate Button
Button 2: This is my XML upload Button
Button 3: This is my XSD validate Button
inputtext: This is my textbox where the xml file location
inputtext2: This is my textbox where the xsd file location
textbox1: this is my output button.
One of the main things im having trouble with is that once my file link shows up to the inputtext, I dont know how to run the validation check on it with the xsd file. I know my code doesnt have any link with the xml and xsd files...its becasue I dont know how to link them. You may assume file names to be sample.xml and sample.xsd. Thanks
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.IO;
using System.Xml;
using System.Xml.Schema;
namespace ValidateXML
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string strXML; //- In put XML file
string strXSD; //- In put XSD file
string strXSDNS;
void ValidateXML(string strXML, string strXSD, string strXSDNS)
{
//Create a XmlValidatingReader, XmlSchemaCollection and ValidationEventHandler objects to be used to validate the XML against an XSD file
XmlValidatingReader reader = null;
XmlSchemaCollection myschema = new XmlSchemaCollection();
ValidationEventHandler eventHandler = new ValidationEventHandler(ShowCompileErrors);
try
{
//Create the XML fragment to be parsed.
XmlDocument doc = new XmlDocument();
doc.Load(strXML);
string xmlFrag = doc.InnerXml;
//Create an XmlParserContext object for use with the XMLValidatingReader:
/////String xmlFrag = "<author xmlns='urn:bookstore-schema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
// "<first-name>Herman</first-name>" +
// "<last-name>Melville</last-name>" +
//"</author>";
//Create the XmlParserContext.
XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None);
//Implement the reader.
reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context);
// Add the relevant schema files (.XSD) to the name space we are checking
//against and repeat until all the schema's have an associated XSD file with them.
//Add the schema.
myschema.Add(strXSD, strXSD);
//Set the schema type and add the schema to the reader.
reader.ValidationType = ValidationType.Schema;
reader.Schemas.Add(myschema);
// Read in the XML Data:
while (reader.Read())
{
}
//If there is no exception, display "Completed Validating" or return a value indicating success
textBox1.Text = "Completed validating " + strXML;
}
//Watch out for exceptions within the XML file and display them appropriately to the user:
catch (XmlException XmlExp)
{
textBox1.Text = "XMLException " + XmlExp.Message;
}
//XMLSchemaExceptions are thrown when the XML document does not match the schema provided.
catch (XmlSchemaException XmlSchExp)
{
textBox1.Text = "XMLSchemaException " + XmlSchExp.Message;
}
//Catch all other exceptions and report them to the user:
catch (Exception GenExp)
{
textBox1.Text = "Exception " + GenExp.Message;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (inputtext.Text == String.Empty)
{
textBox1.Text = ("Warning: Upload a XML file");
}
else if (inputtext2.Text == String.Empty)
{
textBox1.Text = ("Warning: Upload a XSD File");
}
else
{
ValidateXML(strXML, strXSD, "urn:bookstore-schema");
}
}
private void button2_Click(object sender, EventArgs e)
{
// Create an OpenFileDialog object.
OpenFileDialog openFile1 = new OpenFileDialog();
// Initialize the OpenFileDialog to look for text files.
openFile1.Filter = "(*.xml)|*.xml";
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
inputtext.Text = openFile1.FileName;
}
}
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog openFile1 = new OpenFileDialog();
openFile1.Filter = "(*.xsd)|*.xsd";
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
inputtext2.Text = openFile1.FileName;
}
}
}
Thanks in advance for anyone that has helped me.
|
|
|
|
|
This is not an answer to your question, mainly because I have too much difficulty in reading your code, to be able to spot any problems. If you enclose your code in <pre>your code</pre> tags it will be much, much easier to read. The PRE tags maintain the formatting and colourize the code.
You state that
waqasm wrote: Im an extremely new programmer ,
so you have not yet had some bad habits ingrained. Before it becomes too late, each time that you add a Control to a Form give it a name that reflects what it does, e.g. validationButton instead of leaving it as button1 , do this immediately after adding it, before you do anything else like writing a click handler. That way, in six months time, when you look at your code again, you will not be forever thinking, "now what on earth did button1 or textBox1 do?" Some people put the control type first - validationButton would be buttonValidation for them. I use a similar scheme to that except I have, over the years, evolved a set of abbreviations for the controls - 'btn' for a Button, 'txt' for a TextBox, 'lbl' for a Label, 'cbox' for a ComboBox, 'lbox' for a ListBox and so on, so for me it would be btnValidation . Devise whatever you feel comfortable with, but please, please don't just leave them as button1 , button2 and so on.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks Mr Minute for your response. I will keep that in mind for sure.
So i tried debugging my code, and I notice that the code does not go anywhere once I click on the validate button. Meaning it does not go to the validate function. It shows me error as follows "Illegal character paths"
I think the problem is with this function paramters "ValidateXML(strXML, strXSD, "urn:bookstore-schema");"
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Xml;
using System.Xml.Schema;
namespace ValidateXML
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string strXML;
string strXSD;
string strXSDNS;
void ValidateXML(string strXML, string strXSD, string strXSDNS)
{
XmlValidatingReader reader = null;
XmlSchemaCollection myschema = new XmlSchemaCollection();
try
{
StreamReader streamReader = new StreamReader("C:/Umar/1234_H1N1_00002.xml");
strXML = streamReader.ReadToEnd();
streamReader.Close();
StreamReader streamReader1 = new StreamReader("C:/Umar/H1N1_Schema.xsd");
strXSD = streamReader1.ReadToEnd();
streamReader.Close();
XmlDocument doc = new XmlDocument();
doc.Load(strXML);
string xmlFrag = doc.InnerXml;
XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None);
reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context);
myschema.Add(strXSD, strXSD);
reader.ValidationType = ValidationType.Schema;
reader.Schemas.Add(myschema);
while (reader.Read())
{
}
output.Text = "Completed validating " + strXML;
}
catch (XmlException XmlExp)
{
output.Text = "XMLException " + XmlExp.Message;
}
catch (XmlSchemaException XmlSchExp)
{
output.Text = "XMLSchemaException " + XmlSchExp.Message;
}
catch (Exception GenExp)
{
output.Text = "Exception " + GenExp.Message;
}
}
private void btn_Validate_Click(object sender, EventArgs e)
{
String a = null;
String b = null;
if (txt_inputXML.Text == String.Empty)
{
output.Text = ("Warning: Upload a XML file");
}
else if (txt_inputXSD.Text == String.Empty)
{
output.Text = ("Warning: Upload a XSD File");
}
else
{
output.Text = "yoo";
ValidateXML(strXML, strXSD, "urn:bookstore-schema");
}
}
private void btn_BrowseXML_Click(object sender, EventArgs e)
{
OpenFileDialog openFile1 = new OpenFileDialog();
openFile1.Filter = "(*.xml)|*.xml";
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
txt_inputXML.Text = openFile1.FileName;
}
}
private void btn_BrowseXSD_Click(object sender, EventArgs e)
{
OpenFileDialog openFile1 = new OpenFileDialog();
openFile1.Filter = "(*.xsd)|*.xsd";
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
txt_inputXSD.Text = openFile1.FileName;
}
}
}
|
|
|
|
|
waqasm wrote: I think the problem is with this function paramters "ValidateXML(strXML, strXSD, "urn:bookstore-schema");"
I can see nothing wrong with that line as such.
However, there are two things that I have spotted in your ValidateXML method.
The
myschema.Add(strXSD, strXSD);
line is incorrect. It uses strXSD ("urn:bookstore-schema") for both parameters, strXSD is the namespace to use. The second parameter should be the URL of the file containing the schema to use.
Secondly you should not be using XmlSchemaCollection as it is Obsolete unless you are using .Net 1.0 or 1.1.
It will still work but you should really be using XmlSchemaSet instead.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hey,
I fixed what you had asked me to fix. But i am getting this error in my output box. "Exception Illegal characters in path."
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Xml;
using System.Xml.Schema;
namespace ValidateXML
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string strXML;
string strXSD;
string strXSDNS;
void ValidateXML(string strXML, string strXSD, string strXSDNS)
{
XmlValidatingReader reader = null;
XmlSchemaSet myschema = new XmlSchemaSet();
ValidationEventHandler eventHandler = new ValidationEventHandler(ShowCompileErrors);
try
{
XmlDocument doc = new XmlDocument();
doc.Load(strXML);
string xmlFrag = doc.InnerXml;
XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None);
reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context);
myschema.Add(strXSD, "C:/Umar/C:/Umar/H1N1_Schema.xsd");
reader.ValidationType = ValidationType.Schema;
reader.Schemas.Add(myschema);
while (reader.Read())
{
}
output.Text = "Completed validating " + strXML;
}
catch (XmlException XmlExp)
{
output.Text = "XMLException " + XmlExp.Message;
}
catch (XmlSchemaException XmlSchExp)
{
output.Text = "XMLSchemaException " + XmlSchExp.Message;
}
catch (Exception GenExp)
{
output.Text = "Exception " + GenExp.Message;
}
}
private void button1_Click(object sender, EventArgs e)
{
String a = null;
String b = null;
if (txt_inputXML.Text == String.Empty)
{
output.Text = ("Warning: Upload a XML file");
}
else if (txt_inputXSD.Text == String.Empty)
{
output.Text = ("Warning: Upload a XSD File");
}
else
{
output.Text = "yoo";
ValidateXML(strXML, strXSD, "urn:bookstore-schema");
}
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog openFile1 = new OpenFileDialog();
openFile1.Filter = "(*.xml)|*.xml";
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
txt_inputXML.Text = openFile1.FileName;
}
}
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog openFile1 = new OpenFileDialog();
openFile1.Filter = "(*.xsd)|*.xsd";
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
txt_inputXSD.Text = openFile1.FileName;
}
}
}
ps. I was told that this website has tons of experienced programmers?? Why is there only one person helping me out
|
|
|
|
|
There is one obvious line in your code, that might be causing your exception:
myschema.Add(strXSD, "C:/Umar/C:/Umar/H1N1_Schema.xsd");
What is "C:/Umar/C:/Umar/H1N1_Schema.xsd" ?
If it is supposed to be "C:\Umar\H1N1_Schema.xsd" , then try:
myschema.Add(strXSD, @"C:\Umar\H1N1_Schema.xsd");
waqasm wrote: ps. I was told that this website has tons of experienced programmers?? Why is there only one person helping me out
This site does indeed have lots of experienced programmers. All of us help out, when we can, on a voluntary basis. On problems that interest us, for people who give full information about the problems they are having. Little things like what line in the code the error occurs on. Also, in general they do not like to interrupt, unless they see some obviously bad advice.
So, if you do not like the help that you are getting, for free, please feel free to ask elsewhere. If you do, however, I would suggest that you learn to use the debugger, which for all of your problems would have helped you to identify the problems for yourself, and include the information in your question.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Yes, I know the help here is for free. But im sure that everyone benefits from knowledge, whether they are helping someone or being helped. I did manage to use the debugger, so thank you for your professional advice.
Anyhow, the code is finished so anyone having trouble with what I'm doing can benefit from my code.
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Xml;
using System.Xml.Schema;
namespace ValidateXML
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string strXML;
string strXSD;
private void button1_Click(object sender, EventArgs e)
{
if (txt_inputXML.Text == String.Empty)
{
output.Text = ("Warning: Upload a XML file");
}
else if (txt_inputXSD.Text == String.Empty)
{
output.Text = ("Warning: Upload a XSD File");
}
else
{
strXML = txt_inputXML.Text;
strXSD = txt_inputXSD.Text;
XmlValidatingReader reader = null;
XmlSchemaCollection myschema = new XmlSchemaCollection();
try
{
XmlDocument doc = new XmlDocument();
doc.Load(strXML);
string xmlFrag = doc.InnerXml;
XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None);
reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context);
reader.ValidationType = ValidationType.Schema;
myschema.Add("http://tempuri.org/dsMinistryH1N1Export.xsd", strXSD);
reader.Schemas.Add(myschema);
while (reader.Read())
{
}
output.Text = ("Completed validating " + strXML);
}
catch (XmlException XmlExp)
{
output.Text = ("XMLException " + XmlExp.Message);
}
catch (XmlSchemaException XmlSchExp)
{
output.Text = ("XMLSchemaException " + XmlSchExp.Message);
}
catch (Exception GenExp)
{
output.Text = ("Exception " + GenExp.Message);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog openFile1 = new OpenFileDialog();
openFile1.Filter = "(*.xml)|*.xml";
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
txt_inputXML.Text = openFile1.FileName;
}
}
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog openFile1 = new OpenFileDialog();
openFile1.Filter = "(*.xsd)|*.xsd";
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
txt_inputXSD.Text = openFile1.FileName;
}
}
}
}
|
|
|
|
|
SqlCeConnection SqlCeConn = new SqlCeConnection(Information.ConnectionString);
SqlCeCommand SqlCeComm = new
SqlCeCommand("SELECT * FROM SystemUsers ", SqlCeConn);
try
{
if (SqlCeConn.State == ConnectionState.Closed)
SqlCeConn.Open();
SqlCeDataReader SqlRd = SqlCeComm.ExecuteReader();
if (SqlRd.Read()==true){}
when I run this code I get the error below. I could not find the reason behind it. I found that IF the query is wrong this type of error could occur but my query is totally works fine.
There was an error parsing the query. [ Token line number = 1,Token line offset = 8,Token in error = , ]
|
|
|
|
|
try the following...
<code>
public string ExecuteScalar(string strConnectionSring, string strScript)
{
SqlConnection ObjSqlConnection = null;
SqlCommand ObjSqlCommand = null;
ObjSqlConnection = new SqlConnection(strConnectionSring);
string strMessage = null;
try
{
ObjSqlCommand = new SqlCommand(strScript, ObjSqlConnection);
ObjSqlConnection.Open();
ObjSqlCommand.ExecuteScalar();
strMessage = "Succes";
}
catch (Exception ex)
{
strMessage = ex.Message.ToString();
}
finally
{
ObjSqlConnection.Close();
ObjSqlCommand = null;
ObjSqlConnection = null;
strScript = null;
}
return strMessage;
}</code>
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
Thanks
Md. Marufuzzaman
|
|
|
|
|