help needed emailing web from through smtp server

Joined
Nov 12, 2008
Messages
1
Reaction score
0
I have written an enquiry form in asp.net c# and when the send button is clicked i want the info in the form to be emailed to a particulat email address but everytime i click the button i get the following error

Invalid length for a Base-64 char array.

[font=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif] Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Invalid length for a Base-64 char array.


The stact trace is

[/font][font=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif][FormatException: Invalid length for a Base-64 char array.]
System.Convert.FromBase64String(String s) +0
System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob) +29
System.Net.Mail.SmtpNtlmAuthenticationModule.Authenticate(String challenge, NetworkCredential credential, Object sessionCookie) +244
System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +1513
System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +316
System.Net.Mail.SmtpClient.GetConnection() +42
System.Net.Mail.SmtpClient.Send(MailMessage message) +1485

[SmtpException: Failure sending mail.]
System.Net.Mail.SmtpClient.Send(MailMessage message) +2074
Contact.EnquiryButton_Click(Object sender, EventArgs e) in c:\WebDocs\fowlmereplaygroup\Contact.aspx.cs:54
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
[/font]
but i can't work out what is wrong with the code can anyone help

the code i'm using to send the email in my aspx.cs file is

protected void EnquiryButton_Click(object sender, EventArgs e)
{
SmtpClient smtp = new SmtpClient();
MailMessage message = new MailMessage();

// Try to send the message
//try
//{
// Prepare two email addresses
MailAddress fromAddress = new MailAddress("(e-mail address removed)");
MailAddress toAddress = new MailAddress("(e-mail address removed)");

// Prepare the mail message
message.From = fromAddress;
message.To.Add(toAddress);
message.Subject = "Enquiry";
message.IsBodyHtml = true;
message.Body = "<html><body><p> Name:" + HttpUtility.HtmlEncode(Nametxt.Text) + "</p>" +
"<p> Email:" + HttpUtility.HtmlEncode(Emailtxt.Text) + "</p>" +
"<p> Enquiry:" + HttpUtility.HtmlEncode(Enquirytxt.Text) + "</p>" +
"</body></html>";

// Set server details
smtp.Host = "smtp.hosts.co.uk";
smtp.Credentials = new System.Net.NetworkCredential("fowlmereplaygroup.co.uk", "play");

// Send the email
smtp.Send(message);

// Inform the user
Resultlbl.Text = "Message Sent!";
//}
//catch (Exception ex)
//{
// Display error message
//Resultlbl.Text = "Couldn't send the message";
//}
}
 
Back
Top