Can someone tell me if something wrong here?
It seems that this method run without any problem, but the mail never arrives at the email to which it is send.
private bool SendMail()
{
try
{
dsPayPal dp = new datashop.dsPayPal();
MailMessage mail = new MailMessage();
mail.BodyFormat = MailFormat.Text;
mail.From = dp.Email ;
mail.To = dp.Email ;
mail.Subject = GetLang("Assistance Request","お問い合わせ");
mail.Body = GetLang("Name:","姓名:")+txtname.Text.Trim()+ Environment.NewLine +
GetLang("Gender:","性別:")+rbgender.SelectedValue+ Environment.NewLine +
GetLang("Email:","E-mailアドレス")+txtemail.Text.Trim()+ Environment.NewLine +
GetLang("Message:","ご質問:")+ Environment.NewLine + txtmessage.Text.Trim();
mail.Priority = MailPriority.High;
mail.BodyFormat = MailFormat.Text;
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",dp.Email_Name); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",dp.Email_Password); //set your password here
SmtpMail.SmtpServer.Insert(0,dp.SmtpServer);
SmtpMail.Send(mail);
return true;
}
catch(Exception ex)
{
Response.Write(ex.Message);
return false;
}
}Hello Stranger,
Can i ask what email address you are currently trying to send mail to?
The reason that I ask, is that we are experiencing a similar problem in this thread (http://www.vbforums.com/showthread.php?t=460881).
Thanks
Gary
Both the "To" and "From" are set to one of our email addresses here (which works perfectly fine, so it's not with the email).
I outsourced this project, so not sure what the guy said why he did this (His english suck, so does my chinese...so) Something about some mails that can be rejected by certain mail servers, but if we use our own email, it will be fine...basically like sending a mail to yourself.
Not really sure what else I can say. Have you checked the SMTP Server logs to see if that sheds any light?
In the other thread, there is mention of the things to check, and it might be worth looking at dnsreport (http://www.dnsreport.com/) to see if that highlights anything.
Your code itself seems to have everything that I understand it to need, hence the lack of error.
Sorry i can't be more help, but I would be interested to know if you get a resolution, as it may also solve my problem.
Try taking the Try() catch() block out and see if you get a server error screen. If so that should give you more details.
F
Start with the basics. Create a basic email page in your application, hardcode whatever you need to. See if it sends.
Try this page for yourself (http://www.accuracyauto.com/test/testmail.aspx):
I pretty much tried everything I could find google'ing the problem.
Something that seems to be important, is that when I ran this code before on my previous dev machine (which was winXP), it worked fine (using the remote smtp server).
But I changed to a Win2K3 Server machine now (same as my live server) and now I can neither send a mail from my dev or live server.
So must be something with Win2K3.
Here's the code being used (obviously had to remove the userid, password):
try
{
MailMessage mail = new MailMessage();
mail.To = txtRecipient.Text.Trim();
mail.From = txtSender.Text.Trim();
mail.Subject = txtSubject.Text.Trim();
mail.Body = txtMessage.Text.Trim();
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "aaaaaa"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "aaaaaa"); //set your password here
//SmtpMail.SmtpServer = "mail.accuracyauto.com";
SmtpMail.SmtpServer.Insert( 0, "mail.aaaaaaaa.com");
SmtpMail.Send( mail );
Response.Write("Mail Send OK!");
}
catch(Exception ex )
{
Response.Write("The following exception occurred: " + ex.ToString() );
//check the InnerException
while( ex.InnerException != null )
{
Response.Write("----------");
Response.Write("The following InnerException reported: " + ex.InnerException.ToString() + Environment.NewLine );
ex = ex.InnerException;
}
}
no no no...on the server it say mail was send ok. But nothing get delivered.
bliksem!
on my local server, I get this errors:
The following exception occurred: System.Web.HttpException: Could not access 'CDO.Message' object. --> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --> System.Runtime.InteropServices.COMException (0x80040220): The "SendUsing" configuration value is invalid. -- 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 invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) -- End of inner exception stack trace -- at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at accuracyauto.test.testmail.btnSend_Click(Object sender, EventArgs e)----------The following InnerException reported: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --> System.Runtime.InteropServices.COMException (0x80040220): The "SendUsing" configuration value is invalid. -- 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 invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) ----------The following InnerException reported: System.Runtime.InteropServices.COMException (0x80040220): The "SendUsing" configuration value is invalid.
Not to sure if this will make any difference but try adding the mail type:
mail.BodyFormat = MailFormat.Text;
[edit] Whoops...just spotted your first post in which you have this line...
Mendhaaaaaaak!!!!!!!!!!!!!!!!
http://support.microsoft.com/kb/322338
http://www.systemwebmail.com/faq/4.2.2.aspx
Hope they work :blush:
Thanks M. Allthough I did not went through it yet, I'm pretty sure my answer will lie in systemwebmail.com (http://www.systemwebmail.com)
So far saw a good explanation on how to do anything with System.Web.Mail
Will post my solution here, as it seems that, even though this is a common problem, none of the posted solutions elsewhere solves my problem
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment