Re: System.Net.Mail.SmtpClient MailClient message. How do u know if it was successful?



Go here and download the source code.

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry


Try to use other things like gmail or even your home isp.... as experiments.

But the source code will show you other options associated with the mail
object.
Both 1.1 and 2.0 samples are provided.

If you find a resolution, please post it.




if (Sender == "") return;
if (Recipient == "") return;

i'd throw an exception here, else you have no idea it didn't work.

if (string.IsNullOrEmpty ( Sender))
{
throw new ArgumentNullException ( "No Sender Supplied") ; //
}



OT
Here is a good link to exceptional handling:
http://blogs.msdn.com/kcwalina/archive/2005/03/16/396787.aspx


"Claire" <cc@xxxxxxxxxx> wrote in message
news:%23CnP68kFIHA.4228@xxxxxxxxxxxxxxxxxxxxxxx
I'm a noob at emailing from code and I need to add email capabilities to
my application.
The following code completes without exceptions but I'm not receiving any
test emails.
How do you debug this? Ive checked my bad mail folder, and other IIS
similar folders and they're empty.
Can the mail classes be used without having a SMTP server running on
localhost? Can you use any smtp server that's capable of being set up from
a PC, e.g. an ISP account?
If so, do you need to obtain the settings that you might find in an
outlook express email server tab?
Does the MailClient accept all the possible settings via properties?
Are there any recommended freeware/opensource SMTP server .net controls
out there that I could plug into my application so I don't have to require
the user to do any configuration?

thank you
Claire

public void SendEmail(string Sender, string Recipient, string Subject,
string Body)
{
string fnName = "SendEmail";
try
{
if (Sender == "") return;
if (Recipient == "") return;

System.Net.Mail.MailMessage Message = new
System.Net.Mail.MailMessage(Sender,Recipient,Subject,Body);
System.Net.Mail.SmtpClient MailClient = new System.Net.Mail.SmtpClient();
MailClient.Host = "LocalHost";
MailClient.Send(Message);
}
catch (Exception e)
{
LogException(fnName, e);
throw e;
}
}// function



.



Relevant Pages

  • Re: XML Signature, how to sign?
    ... > trying to compile my source code, ... > Orginal Exception was ... > org.apache.xml.security.transforms.TransformationException: The XPath is not ... public static void sign(Document doc, String keystore, String ...
    (comp.lang.java.programmer)
  • Re: Dotfuscator - major flaw in Microsoft dotNET?
    ... NET assembly and convert it back into source code such as .NET ... The idea of obfuscation is to make the goal of reverse ... value of the string used in reflection or dynamic class loading, ... With Dotfuscator Professional Edition, ...
    (microsoft.public.dotnet.general)
  • Re: "NUL" device is missing
    ... > required for a specified formating string. ... I spent quite a bit of time last night reviewing the source code for the ... It is encouraging to hear than an updated ANSI C standard does finally ...
    (microsoft.public.windowsxp.embedded)
  • Re: sorting dates
    ... The reason I am so late in responding is that I had many years of source code to go through in order to accurately verify the origin of my idea so that there could be no questions. ... at the "engine level" of JS's sort routine is STILL the character by character comparison and whether you chop the string in sections of 8 or not, you still have string data types. ... Sort speed of Strings will not depend on the exact identity of the characters in them; so one can meaningfully compare the comparison speed of Strings like "12345678" with that of Numbers like 12345678, each being adequately representative of the general case. ... **after about 1000 elements, quicksort's efficiency rapidly decays, ...
    (comp.lang.javascript)
  • Re: dynamicly build a list of strings?
    ... strlcpy guarantees null termination ... the string buffer with redundant NULs. ... count of characters and then manually terminate the string). ... The source code for this function was obtained from the ...
    (comp.lang.c)