By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,491 Members | 3,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,491 IT Pros & Developers. It's quick & easy.

Problem with email sending in asp.net

P: 2
hi,

i have problem in email sending to 1and1 server...

the error given below

System.Web.HttpException: At least one of the From or Sender fields is required, and neither was found. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x8004020D): At least one of the From or Sender fields is required, and neither was found. --- End of inner exception stack trace --- at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Web.Mail.SmtpMail.LateBoundAccessHelper.Cal lMethod(Object obj, String methodName, Object[] args) --- End of inner exception stack trace --- at System.Web.Mail.SmtpMail.LateBoundAccessHelper.Cal lMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMes sage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at VerveMedia.Mail.VerveMail.Send() in e:\kunden\homepages\37\d230758663\App_Code\VerveMa il.cs:line 151 at RecruiterRegistration.CreateUserWizard1_CreatedUse r(Object sender, EventArgs e) in e:\kunden\homepages\37\d230758663\RecruiterRegistr ation.aspx.cs:line 139 >


Any body can help me very urgent


Thanks
yuvaraj.R
Jan 25 '08 #1
Share this Question
Share on Google+
3 Replies


debasisdas
Expert 5K+
P: 8,127
What is the code that is throwing this error ?
Jan 25 '08 #2

P: 2
What is the code that is throwing this error ?

this is the code


using System;
using System.Text;
using System.Web.Mail;

namespace Verve.Mail
{
public class Verve
{
public Verve() { }

string from, to, cc, bcc, subject, body, smtpServerName;



public string From
{
set
{
from = value;
}
}

public string To
{
set
{
to = value;
}
}

public string Cc
{
set
{
cc = value;
}
}

public string Bcc
{
set
{
bcc = value;
}
}

public string Subject
{
set
{
subject = value;
}
}

public string Body
{
set
{
body = value;
}
}


public void Send()
{


// Build HTML Body

StringBuilder sb = new StringBuilder();

sb.Append("<html>");
sb.Append("<head>");
sb.Append("<meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>");
sb.Append("<title>just4telecom.com</title>");
sb.Append("<style>");
sb.Append(".ver8 { font-family: Verdana; font-size: 8pt; text-align: justify; line-height: 200% }");
sb.Append("</style>");
sb.Append("</head>");
sb.Append("<body link='#1865AD' vlink='#1865AD' alink='#1865AD'>");
sb.Append("<table border='0' cellpadding='0' cellspacing='0' width='100%' id='table1'>");
sb.Append("<tr>");
sb.Append("<td align='center' valign='top'>");
sb.Append("<table border='0' cellpadding='0' cellspacing='0' width='85%' id='table2'>");
sb.Append("<tr>");
sb.Append("<td></td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td>");
sb.Append("<img border='0' src='http://just4telecom.com/images/just4telecom.jpg'></td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td><hr noshade size='1' color='#E9E9E9'></td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td></td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td class='ver8'></td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td class='ver8'>" + body + "</td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td class='ver8'></td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td></td>");
sb.Append("</tr>");
sb.Append("</table>");
sb.Append("</td>");
sb.Append("</tr>");
sb.Append("</table>");

sb.Append("</body>");

sb.Append("</html>");

MailMessage objMail = new MailMessage();

if (from == null)
{
from = "info@just4telecom.com";
}
else
{
objMail.From = from;
}
objMail.To = to;

if (cc != null)
{
objMail.Cc = cc;
}

if (bcc != null)
{
objMail.Bcc = bcc;
}
if (subject == null)
{
Subject = "Resume to just4telecom.com";
}

objMail.Subject = subject;
objMail.BodyFormat = MailFormat.Html;
objMail.Body = sb.ToString();
objMail.Priority = MailPriority.Normal;
SmtpMail.SmtpServer = "smtp.1and1.com";
SmtpMail.Send(objMail);
}
}
}
Jan 25 '08 #3

harshmaul
Expert 100+
P: 490
If you server needs to go through a proxy to access a remote smtp server you might need to give the code proxy settings.....

strWebProxy = "123.123.123.123:8080";
strProxyUser = "user";
strProxyPassword = "password";

WebProxy p = new WebProxy(strWebProxy, true);
p.Credentials = new NetworkCredential(strProxyUser, strProxyPassword);
GlobalProxySelection.Select = p;
Jan 25 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.