how can i send an email as a part of a gmail-conversation via smtp?
Taking the same subject doesnt work...
tell me if you need more infos...
thanks in advance!
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("#googlemail.com");
mail.To.Add("#.com");
mail.Subject = "(Somee.com notification) New order confirmation";
mail.Body = "(Somee.com notification) New order confirmation";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("", "");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
You'll need to use the following:
mail.Headers.Add("In-Reply-To", <messageid>);
The message id you should be able to get from the previous email's headers. Just look for "Message-Id".
This answer gives a few more headers you may want to add to try help threading in other clients. It seems maybe gmail is now using these, too.
Related
I'm trying to send an email via .net smtp. I am receiving this message:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("server", 587);
SmtpServer.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
SmtpServer.UseDefaultCredentials = false;
SmtpServer.EnableSsl = false;
SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
mail.From = new MailAddress(FromMail);
mail.To.Add("emailaddress");
mail.Bcc.Add("emailaddress");
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
SmtpServer.Send(mail);
The issue I believe is that the servers are located in the DMZ...anyone have any insight on how to fix this? If we assign the user with domain admin rights, the emails work...due to security reasons we don't want to go that route.
Issue resolved...the network team didn't have port 587 available...once they added it, emails started working for anonymous sender. I no longer need to use credentials. Thanks to all who replied.
Hi guys I create a mail class to send emails.
public void SendEmail(string subject, string messageBody, string toAddress)
{
MailMessage mail = new MailMessage();
mail.To.Add(toAddress);
//mail.To.Add("amit_jain_online#yahoo.com");
mail.From = new MailAddress("noreply3ncra#gmail.com");
mail.Subject = subject;
string Body = messageBody;
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.UseDefaultCredentials = false;
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("noreply3ncra#gmail.com", "********");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
}
But I got this error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
So I have to sign into Gmail and enter the captcha code and after this every thing is going to be ok.
What should I do?
Try this:
You should enable application to access gmail account.
Try this link:
Gmail allow access
For more info refer this link:
Stackoverflow link
Add this also:
Add port no also to your code as:
smtp.Port = 587;
For more info refer this link:
Codeproject link
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
smtpClient.Credentials = new System.Net.NetworkCredential("gmailId", "Password");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
MailMessage mail = new MailMessage();
mail.From = new MailAddress("gmailId", "Testing Mail");
mail.To.Add(new MailAddress("someMailId"));
mail.Body = "This is a test email. Please ignore or delete.";
mail.Subject = "Mail Testing";
smtpClient.Send(mail);
I am trying to use the code above to send mail. It was working fine for me, but when I tried to use it in another system it gave me an error ("Unable to connect to the remote server").
I think your gmail account is secured with mobile sms facility. If you access your gmail account from other macine than a sms will recieve from gmail for varification.
Please off this functionality and try again.
I want to select file and send to employees.
employee's(recipient) email I am reading from excel.
Sender's email is set to my code.
MailMessage mail = new MailMessage();
mail.Attachments.Add(new System.Net.Mail.Attachment(attach));
mail.To.Add(sendmail);
mail.From = new MailAddress(SenderEmail);
mail.Subject = "Payroll";
string body = "Hi, payroll";
mail.Body = body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("sendermail", "pwd");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Send(mail);
Now I want to read sender's email & password from a textbox,and pass.
Now error occuring like this
The SMTP server requires a secure connection or the client was not
authenticated. The server response was: 5.5.1 Authentication Required.
Learn more at
I coded smtpclient host as gmail and corresponding port.
But I want to send from other account means in yahoo,live etc..
How can it possible? But even gmail is also giving error.Can anybody help?
error is getting when reading from textbox
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com");
smtpClient.Credentials = new NetworkCredential("xxxxx#gmail.com", "password");
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
MailMessage mail = new MailMessage();
//mail.From = new MailAddress("xxx1#gmail.com");
mail.To.Add("XX2#gmail.com");
mail.Subject = "Test mail";
mail.Body = "This is test mail, with test content";
smtpClient.Send(mail);
In the above code, why mail.From is mandatory? even I specified mail-id in smtpClient.Credentials.
Even I specified mail.From with some mail-id, the receiver is not receiving mail from this mail address, instead receiving from xxxxx#gmail.com which I specified in smtpClient.Credentials.
From is supposed to be the address from where the mail was sent.
This can be different from your Smtp credentials. Some servers will let you have a username that is different from your mail address.
Gmail shows the email address from where it received the mail.
They do that so that users don't mistake getting the mail from someone who didn't really send it.
Not all email clients do that.
You cannot fake a from address to gmail. They will always show where they got the email from.