|
Amol Parsewar wrote: my code is as given below : That's a class. According to my first Google-results, you'll need a bit more to do a search.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
I am using the following code to lop through contracts and send email to concern people. Same contract will have multiple people like a hardware contract should have IT and purchase emails in it. I am able to get the emails but the problem if there are two emails in the contract (john & smith) it will send two emails to john and two emails to smith.
John will receive the email saying Dear John and anther email saying Dear Smith.. similarly with Smith!
here is my code:
while (sql_reader.Read())
{
contract_id = Convert.ToInt32(sql_reader["contract_id"]);
mail.To.Add(sql_reader["reminder_email"].ToString());
mail.Subject = sql_reader["contract_name"].ToString();
mail.Body = email_body.ToString();
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("it@mydomain.com", "mypassword");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
}
Technology News @ www.JassimRahma.com
|
|
|
|
|
So keep a list of email addresses you have already sent to, and check it before sending.
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
In your SQL, sort by the email address and then keep a flag to see if the email your processing is the same as the last and if so don't send the email.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
You're reusing the same "mail" (MailMessage) object in your loop.
You should use a new MailMessage object for each recipient ("To") ... or at least clear the "To" collection before adding a recipient and sending.
|
|
|
|
|
During an Interview I get this interesting question:
What are the 5 classes you use most often?
What is the best answer to this question? Keeping in mind that this is an interview question what will be your answer?
|
|
|
|
|
B413 wrote: What is the best answer to this question
It would be the names of the classes that you use most often. Which classes those are probably going to depend on the projects and the types of projects you have worked on.
You can lead a developer to CodeProject, but you can't make them think.
The Theory of Gravity was invented for the sole purpose of distracting you from investigating the scientific fact that the Earth sucks.
|
|
|
|
|
string
All five of my top 5 would be string .
You try building a UI without them!
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
System.Object
System.Diagnostics.Debug
System.Collections.Generic.List
System.Convert
System.Action
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I also responded Object first because of the word "used" then I answered things like String, List, Int and Debug. This seems to me so basic than I hesitated to answer that. Happy to see I'm not alone.
|
|
|
|
|
Do note that Int isn't a class : it's a struct ...
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
In answer to your email (the question appears to have vanished):
Int is a synonym for Int32 , and Int16 , Int32 , and Int64 are all struct
Have a look here: Using struct and class - what's that all about?[^] - it tries to explain the difference.
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
Interesting that System.Convert is in there. I think I've only ever used it about twice (well directly, anyway).
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote:
Interesting that System.Convert is in there |
Most people don't "like" the class. It's not interesting which is better, what is interesting is whether the *interviewer* would ask why I choose the class. Chances are, the question never comes.
static void Main(string[] args)
{
string s = null;
Console.WriteLine((string)s);
Console.WriteLine("" + s);
Console.WriteLine(Convert.ToString(s));
Console.ReadLine();
}
Now, an object that can contain null would not be casted to an Int - most people would parse it (and ignore any conversion errors). If prefer to convert it all if there's a lot of different types after another that need to be assigned. Otherwise, I go for casting.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You use Object itself more than say String?
|
|
|
|
|
jschell wrote:
You use Object itself more than say String? Dunno, I did not measure them - just the first five non-structs that popped into my head. A string is still a pointer to an array of bytes to me. Nothing fancy, just an address. Outside of that, it's a shame Interfaces were not included, it would have made the answer much more interesting.
Given inheritance, I'd say I use a LOT of Object
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
I responded Object first then String, List, maybe Int even it's a struct and Debug, Console, something like that.
|
|
|
|
|
This is where you wished you'd remember something absurdly obscure like AsyncStateMachineAttribute.
|
|
|
|
|
B413 wrote: What is the best answer to this question?
If an interviewer thinks there is a best answer to that question then you can be sure that the interviewer doesn't know what they are doing. At best they don't understand the interview process and at worst they are arrogant.
There are of course bad answers to that question - like "what is a class?"
|
|
|
|
|
system.web.ui
system.io
system.data
system.configuration
system.data.sql

|
|
|
|
|
System.web.ui
system.io
system.data
system.data.sqlclient
system.configuration 
|
|
|
|
|
|
Suspicious link is suspicious. And "not an image". Try this one: http://i.imgur.com/NzoGrFa.png[^]
This looks trivial to OCR. That term should get you started.
|
|
|
|
|
The technique you are looking for is Optical Character Recognition. Good luck.
|
|
|
|