|
I'm trying to build a little C# program using regular expressions that will filter out the email address and the reason for the mail not reachin the destination.
All that I really want is to extract the email address and the specific reason why the message wasn't sent or recieved.
Example:
Hi. This is the qmail-send program at domain.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.
email address@domain.com:
Sorry, no mailbox here by that name. (#5.1.1)
Thanks in advance for the help.
Regards
Jorge
-- modified at 6:34 Sunday 14th May, 2006
|
|
|
|
|
email\s([^@]+@[^@]+) r|\n|\r\n)+(.*)
This is very basic, but should get the work done.
match[1] is the mail address, match[3] is the reason of the failure.
regards
-- modified 12-Sep-18 21:01pm.
|
|
|
|
|
hello
maybe you can help me to make a comobox to get the values from DB .
and how can I know and save what was picked there.?
thank you
|
|
|
|
|
combobox1.DataSource = ds.Tables[0];
combobox1.TextMember = "<field>"; // I think it's textdatamember, or text, this is the name of the field you want that the user will see
combobox1.ValueDataMember = "<field>"; // this is what you want to know, eg. ID
to get it you do combobox1.Items.SelectedItems - will get the collection of the selected items, and by the indexer you can watch what you want.
|
|
|
|
|
|
Hi i am using VS 2003 , and i want to break at a particular place when a value of object x is changed. IN VB6 we have something called Watchwindows, where we can set a condition when value changes to break
san
|
|
|
|
|
In Visual Studio there is a breakpoints window where you can set conditions for breakpoints.
---
b { font-weight: normal; }
|
|
|
|
|
I'm trying to establish a good way of doing something before finalising my codegen.
Below is an example:
private void Form1_Load(object sender, EventArgs e)
{
Employee emp = ReallyCoolFuncSingle();
}
public Employee ReallyCoolFuncSingle()
{
Employee e = new Employee();
Person p = CoolFuncSingle();
e = (Employee)p;
e.Age = "100";
return e;
}
public Person CoolFuncSingle()
{
Person p = new Person();
p.PersonName="billy bob";
return p;
}
public Person[] CoolFuncArray()
{
Person[] p = new Person[2];
p[0] = new Person();
p[1] = new Person();
p[0].PersonName = "billy bob";
p[1].PersonName = "frank";
return p;
}
public class Person
{
private string _PersonName;
public string PersonName
{
get { return _PersonName; }
set { _PersonName = value; }
}
public static explicit operator Person(Employee e)
{
Person p = new Person();
p.PersonName = e.PersonName;
return p;
}
}
public class Employee
{
#region person stuff
private string _PersonName;
public string PersonName
{
get { return _PersonName; }
set { _PersonName = value; }
}
#endregion
private string _Age;
public string Age
{
get { return _Age; }
set { _Age = value; }
}
public static explicit operator Employee(Person p)
{
Employee e = new Employee();
e.PersonName = p.PersonName;
return e;
}
}
In essence, I'm trying to modify the Person object returned from some functions and return a super class of some sort - whether actually derived or not is not the issue.
It's a wrap and modify type of pattern.
The code above shows a few attempts.
Basically it all works fine for single objects (managed to get around the explicit operator restrictions), but won't work for arrays.
Any ideas?
Cheers,
Simon
> blog:: brokenkeyboards
> what I think of the OPTIONAL keyword in VB.NET? :: here
> CV :: PDF
> skype :: SimonMStewart
|
|
|
|
|
Although I don't have a clue what you want to accomplish with this weird code (why not just let Employee be a subclass of Person?) I'll try to help you:
It won't work for arrays . The problem is that there is no way to defined operators for arrays of a given type. But you can nevertheless transfer its elements one by one to a new array:
Person[] persons = GetMyPersonsArray();
Emplyee[] employess = new Employee[persons.Length];
for (int i = 0; i < persons.Length; i++)
employess[i] = (Employee)persons[i];
-- modified at 4:23 Sunday 14th May, 2006
|
|
|
|
|
Robert Rohde wrote: The problem is that there is no way to defined operators for arrays of a given type.
But others can reference array parameters ie
public static explicit string[] operator (Employee e){}
PS: I allways forget the syntax, could wrong :p
|
|
|
|
|
Yes, but either the return value or the parameter must exactly match the class which is defined in. Thus in your case either return type or parameter type must be Employee and so something like public static explicit Person[] operator (Employee[] e){} is not possible (neither return type nor parameter type is Employee).
|
|
|
|
|
this is the route I want to go.
More like (pseudo code):
public static explicit operator Person[] Employee(Person p)
{
Employee e = new Employee();
e.PersonName = p.PersonName;
return e;
}
So, the Employee object knows how to cast from Person[] to Employee[].
I could go the route of a static function on Employee, but was hoping for something a little more correct.
Cheers,
Simon
> blog:: brokenkeyboards
> what I think of the OPTIONAL keyword in VB.NET? :: here
> CV :: PDF
> skype :: SimonMStewart
|
|
|
|
|
Hi everyone. I just figured this out and I thought I should put it up somewhere in case someone else has spent hours looking for it like I did. Ok maybe not hours...but still. Anyways heres how you can convert a string to any .NET type that can parse a string.
((IConvertible)"1024").ToType(<br />
Type.GetType("System.Int64"),<br />
System.Globalization.CultureInfo.CurrentCulture )<br />
((IConvertible)"5/5/1985").ToType(<br />
Type.GetType("System.DateTime"),<br />
System.Globalization.CultureInfo.CurrentCulture )<br />
((IConvertible)"1024").ToType(<br />
Type.GetType("System.Double"),<br />
System.Globalization.CultureInfo.CurrentCulture )
returns:
1024
5/5/1985
1024.0
I use Type.GetType instead of typeof() because this way we could pass in a string to get type describing what values to convert to. So a potential function could look like this...
object ConvertString(string str_to_convert, string type_to_convert)<br />
{<br />
return ((IConvertible)str_to_convert).ToType(<br />
Type.GetType(type_to_convert),<br />
System.Globalization.CultureInfo.CurrentCulture )<br />
}
|
|
|
|
|
How about using Convert.ChangeType(str_to_convert, Type.GetType(type_to_convert)) ?
|
|
|
|
|
that works
|
|
|
|
|
Hello everyone,
I would like to read an 16-bit signed tif image in my program.
I used GetPixel(x, y) and the pointer method introduced in "Image processing with dummies" but in both case the program give me the message
"OutOfMemoryException".
Could every one help me to read this image or in a ESRI GRID Raster format.
Regards
Isaac
|
|
|
|
|
I would like to develop a scanner software and make it available as freeware for everyone to download and install. The software including the following functions:
1. Scan to File.
2. Scan to Fax.
3. Scan to Email.
4. Photocopy.
5. Others.
I had created a ComboBox. I want the ComboBox to list down all the scanner drivers installed in user's computer, including the TWAIN drivers. Can anybody tell me how to do that?
|
|
|
|
|
How can I search for a USB PNP ID?
For example, when you run "msinfo32.exe" and then expand "Components/USB", it lists all the USB devices as well as their "PNP Device ID".
I tried using This Code[^]; however, it doesn't list my USB device, although it does work properly by detecting the mouse and some other devices.
One thing I noticed is that all the devices that the code above finds start with "HID" in the msinfo32.exe "PNP Device ID"; however, my device starts with USB. My device id is: USB\VID_0403&PID_6001.
-- modified at 20:26 Saturday 13th May, 2006
|
|
|
|
|
I figured it out by using ManagementObjectSearcher class. Wow! This class is really powerful if you ever need to figure out anything from your hardware.
Here is the code:
<br />
string device = "Win32_USBHub";<br />
ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from " + device);<br />
foreach(ManagementObject mo in searcher.Get())<br />
{<br />
Trace.WriteLine(mo.GetPropertyValue("Name")+" "+ mo.GetPropertyValue("PNPDeviceID"));<br />
}<br />
Note that there are a ton of hardware classes available from here[^].
Each class has several variables that can be accessed using the GetPropertyValue method.
|
|
|
|
|
So I have this class, AdminPaper and it implements, IComparable to sort an array of AdminPapers by a property of AdminPaper.
The implementation looks like this:
public int CompareTo(object obj)
{
AdminPaper paper = (AdminPaper)obj;
if (this.scoreDouble > paper.scoreDouble)
{
return -1;
}
else if (this.scoreDouble < paper.scoreDouble)
{
return +1;
}
else
return 0;
}
So, this code will sort my array list based upon the scoreDouble field. And this works great, I just call it like this, Array.Sort(papers); , where papers is an un-sorted array of AdminPapers.
However, what if I want to sort papers a different way? Right now I only can sort the way I implemented Icomparable in AdminPapers . Is there a way to have two implementations? How do I do this? Right now the only sorting method I have is the CompareTo method above, is there a way to implement another?
/\ |_ E X E GG
-- modified at 20:48 Saturday 13th May, 2006
|
|
|
|
|
see IComparer. You can create several of them or have one that provides some mechanism to control what to sort on.
good luck
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
Here are two options:
1) Implement IComparable in the AdminPaper class and create a static property which determines the comparison mode to use. Inside of your IComparable implementation perform the appropriate comparison based on the property value.
2) Create multiple implementations of IComparer in separate classes (one class per implementation). Have one static property for every IComparer implementation in the AdminPaper class (returning a singleton instance from each static property). Pass the appropriate IComparer implementation as the second argument to the Sort method of Array .
Josh
-- modified at 23:48 Saturday 13th May, 2006
BTW - If you go with option (2) you'd probably want to make the classes that implement IComparer private nested classes within the AdminPaper class, just to avoid namespace pollution.
|
|
|
|
|
i want to insert a new row inside my microsoft access database, i do it, but i need it immediately. how?
|
|
|
|
|
Although this is a question to database forum (if there is), I know a little about it so I'll help...
I personally work with database that doesn't stop to work (there are always a few people that can use the database), you should always take that risk! because if some-one inserts a row while you insert a row, you can both edit the same row in the end.
I'll show you the command line for the last inserted row, and then I'm going to show you the better way.
So this is command to get the last row:
Select Top 1 * From tblTable Order By <id-field> DESC
(ofcourse no case-sensetive in here) tblTable = the table
ID-Field = the ID or some other field that increases by time (eg. Date\Time)
Now this is not good because if two people add a row, at the same time, they will, in the end see the same row, the last row inserted, and not their own.
The better way which I prefer is to save the variables from the insert command, and just do a "Where" statement in the select command.
eg: Select * from tblTable Where <field1> = '{0}' And <field2> = '{1}' etc. etc...
Hope I helped... NaNg
|
|
|
|
|
Hi!
Don't know if I understand what you want, but if you need the value of an AutoValue that Access has assigned to a field in your newly-inserted row, you can look for "@@Identity".
Another way could be to create your IDs on your own - use a GUID and you can be sure that it's unique and you have its value before you even insert the row into the database.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|