-
Send Mail Using C#
I cant do this..
I have this code:
Code:
static void Main(string[] args)
{
MailMessage mailMsg = new MailMessage();
mailMsg .From = "[email protected]";
mailMsg .To = "[email protected]";
mailMsg .Cc = "[email protected]";
mailMsg .Bcc = "[email protected]";
mailMsg .Subject = "SubjectOfTheMailString";
mailMsg .Body = "BodyOfTheMailString";
smtpmail .Send(mailMsg);
Console.ReadKey();
}
And every line is an error.. Why?
-
Re: Send Mail Using C#
you should declare the "smtpmail" object and use your mail server
-
Re: Send Mail Using C#
Every line is an error? What error? If we don't know what the errors are we can't tell you what the errors are. Chances are you have added the required reference and/or import to your project. You haven't told us what version you're using so we don't know whether to advise you to use System.Web.Mail or System.Net.Mail. Please always specify your version when posting a question and always give details of errors. Otherwise we have to guess.
-
Re: Send Mail Using C#
My guess is, you're trying to use that C# code in a VB.NET application. That would be perfectly plausible since every line is an error. :)
-
Re: Send Mail Using C#
Remove the space before the dynamic member access operator on each line.
-
Re: Send Mail Using C#
D'oh.
D'ohest thing ever. :)