0

Been sending emails from my C# application for awhile now. But tried tonight, and its not working. Been googling but have to come across anything anything with the exception message I am getting.

Exception: System.Net.Mail.SmtpException

Message: Mailbox unavailable. The server response was: 5.7.1 The message contains an unauthorized custom from address because the <--- this is where the message ends, not much help.

MailMessage _Mail;
_Mail = new MailMessage("myEmailAddress@gmail.com", "friendsEmail@elseWhere.com");
_Mail.Subject = "Subject";
_Mail.IsBodyHtml = true;

// Create HTML body  
var htmlBody = "...";

_Mail.Body = htmlBody;

SmtpClient client = new SmtpClient();
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("myEmailAddress@gmail.com","password");
client.Send(_Mail);

Any idea what is wrong?

Edit: I am using .Net 3.5

ZioN
  • 550
  • 2
  • 11
  • 35
  • Get the full text of the email and add it to your question (edit any real email addresses). To learn how, see http://stackoverflow.com/questions/7515457/convert-mailmessage-to-raw-text – Eric J. Aug 06 '14 at 18:14
  • @EricJ. I tried your suggestion, but I get a `System.Reflection.TargetInvocationException was unhandled` Exception seems to be coming from `SendMethod.Invoke` call in the `RawMessage` method – ZioN Aug 06 '14 at 18:27
  • I'm not sure, but it seems the code in that answer targeted .NET 4.0. Can you write a simple test program with your sending code and the reflection code targeting .NET 4.0? – Eric J. Aug 06 '14 at 18:50
  • @EricJ. It seems to be working again. And all I did was nothing... must have been an issue on Gmail's side. – ZioN Aug 06 '14 at 18:57

1 Answers1

0

Well my C# application is working again. It must have been a problem on Gmail side. It would be insightful if someone can explain the reason.

ZioN
  • 550
  • 2
  • 11
  • 35