Sending mails doesn't work. I'm not sure if it's something with client settings or mail server...
When using Gmail SMTP server I got "Connection closed" exception, when changing port to 587 I get "Authentication required" message. What's more interesting when changing SMTP server to something different (smtp.poczta.onet.pl) I get "Time out" exception after ~100s
Here's the code:
protected void SendMessage(object sender, EventArgs e)
{
// receiver address
string to = "******#student.uj.edu.pl";
// mail (sender) address
string from = "******#gmail.com";
// SMTP server address
string server = "smtp.gmail.com";
// mail password
string password = "************";
MailMessage message = new MailMessage(from, to);
// message title
message.Subject = TextBox1.Text;
// message body
message.Body = TextBox3.Text + " otrzymane " + DateTime.Now.ToString() + " od: " + TextBox2.Text;
SmtpClient client = new SmtpClient(server, 587);
client.Credentials = new System.Net.NetworkCredential(from, password);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.EnableSsl = true;
try
{
client.Send(message);
// ui confirmation
TextBox3.Text = "Wysłano wiadmość!";
// disable button
Button1.Enabled = false;
}
catch (Exception ex)
{
// error message
TextBox3.Text = "Problem z wysłaniem wiadomości (" + ex.ToString() + ")";
}
}
I've just read that google don't support some less secure apps (3rd party apps to sign in to Google Account using username and password only) since 30/05/22. Unfortunately can't change it because I have two-stage verification account. Might it be connected? Or is it something with my code?
Gmail doesn't allow, or want you to do that with passwords anymore. They ask you to create a credentials files and then use a token.json to send email.
Using their API from Google.Apis.Gmail.v1 - from Nuget. Here is a method I made and test that is working with gmail.
void Main()
{
UserCredential credential;
using (var stream =
new FileStream(#"C:\credentials.json", FileMode.Open, FileAccess.Read))
{
// The file token.json stores the user's access and refresh tokens, and is created
// automatically when the authorization flow completes for the first time.
string credPath = "token.json";
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
// Create Gmail API service.
var service = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
// Define parameters of request.
UsersResource.LabelsResource.ListRequest request = service.Users.Labels.List("me");
// List labels.
IList<Label> labels = request.Execute().Labels;
Console.WriteLine("Labels:");
if (labels != null && labels.Count > 0)
{
foreach (var labelItem in labels)
{
Console.WriteLine("{0}", labelItem.Name);
}
}
else
{
Console.WriteLine("No labels found.");
}
//Console.Read();
var msg = new Google.Apis.Gmail.v1.Data.Message();
MimeMessage message = new MimeMessage();
message.To.Add(new MailboxAddress("", "toemail.com"));
message.From.Add(new MailboxAddress("Some Name", "YourGmailGoesHere#gmail.com"));
message.Subject = "Test email with Mime Message";
message.Body = new TextPart("html") {Text = "<h1>This</h1> is a body..."};
var ms = new MemoryStream();
message.WriteTo(ms);
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
string rawString = sr.ReadToEnd();
byte[] raw = System.Text.Encoding.UTF8.GetBytes(rawString);
msg.Raw = System.Convert.ToBase64String(raw);
var res = service.Users.Messages.Send(msg, "me").Execute();
res.Dump();
}
static string[] Scopes = { GmailService.Scope.GmailSend, GmailService.Scope.GmailLabels, GmailService.Scope.GmailCompose, GmailService.Scope.MailGoogleCom};
static string ApplicationName = "Gmail API Send Email";
Enable 2FA on your email and generate a password for your application using the link. As far as I know, login and password authorization using unauthorized developer programs is no longer supported by Google.
Can you ping the smpt server from your machine or the machine you deploy the code from? THis could be a DNS issue.
Related
I'm trying to send mail using SendGrid but I can't. It always throws an exception that I can't fix.
How do I to fix this issue ?
SendMail
public static Boolean isSend(IList<String> emailTo, String mensagem, String assunto, String emailFrom, String emailFromName){
try{
MailMessage mail = new MailMessage();
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.SubjectEncoding = System.Text.Encoding.UTF8;
//to
foreach (String e in emailTo) {
mail.To.Add(e);
}
mail.From = new MailAddress(emailFrom);
mail.Subject = assunto;
mail.Body = mensagem;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = CustomEmail.SENDGRID_SMTP_SERVER;
smtp.Port = CustomEmail.SENDGRID_PORT_587;
smtp.Credentials = new System.Net.NetworkCredential(CustomEmail.SENDGRID_API_KEY_USERNAME, CustomEmail.SENDGRID_API_KEY_PASSWORD);
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = false;
smtp.Timeout = 20000;
smtp.Send(mail);
return true;
}catch (SmtpException e){
Debug.WriteLine(e.Message);
return false;
}
}
CustomMail
//SendGrid Configs
public const String SENDGRID_SMTP_SERVER = "smtp.sendgrid.net";
public const int SENDGRID_PORT_587 = 587;
public const String SENDGRID_API_KEY_USERNAME = "apikey"; //myself
public const String SENDGRID_API_KEY_PASSWORD = "SG.xx-xxxxxxxxxxxxxxxxxxxxxxxxx-E";
Exception
Exception thrown: 'System.Net.Mail.SmtpException' in System.dll
Server Answer: Unauthenticated senders not allowed
For sending emails with SendGrid there is v3 API. The NuGet name is SendGrid and the link is here.
This library does not work with System.Net.Mail.MailMessage, it uses SendGrid.Helpers.Mail.SendGridMessage.
This library uses an API key for authorization. You can create one when you log into SendGrid web app, and navigate to Email API -> Integration Guide -> Web API -> C#.
var client = new SendGridClient(apiKey);
var msg = MailHelper.CreateSingleTemplateEmail(from, new EmailAddress(to), templateId, dynamicTemplateData);
try
{
var response = client.SendEmailAsync(msg).Result;
if (response.StatusCode != HttpStatusCode.OK
&& response.StatusCode != HttpStatusCode.Accepted)
{
var errorMessage = response.Body.ReadAsStringAsync().Result;
throw new Exception($"Failed to send mail to {to}, status code {response.StatusCode}, {errorMessage}");
}
}
catch (WebException exc)
{
throw new WebException(new StreamReader(exc.Response.GetResponseStream()).ReadToEnd(), exc);
}
I think your problem stems from not instantiating the SMTP client with the server in the constructor. Also you should wrap your smtpclient in a using statement so it disposes of it properly, or call dispose once you're finished.
Try this:
public static Boolean isSend(IList<String> emailTo, String mensagem, String assunto, String emailFrom, String emailFromName)
{
try
{
MailMessage mail = new MailMessage();
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.SubjectEncoding = System.Text.Encoding.UTF8;
//to
foreach (String e in emailTo)
{
mail.To.Add(e);
}
mail.From = new MailAddress(emailFrom);
mail.Subject = assunto;
mail.Body = mensagem;
mail.IsBodyHtml = true;
using(SmtpClient smtp = new SmtpClient(CustomEmail.SENDGRID_SMTP_SERVER)){
smtp.Port = CustomEmail.SENDGRID_PORT_587;
smtp.Credentials = new System.Net.NetworkCredential(CustomEmail.SENDGRID_API_KEY_USERNAME, CustomEmail.SENDGRID_API_KEY_PASSWORD);
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = false;
smtp.Timeout = 20000;
smtp.Send(mail)
}
}
catch (SmtpException e)
{
Debug.WriteLine(e.Message);
return false;
}
}
If that doesn't work you could try removing the port, enablessl and usedefaultcredentials parameters for the smtp client. I use sendgrid all the time and don't use those options.
To more specifically answer your original question and the cause of your exception, the SendGrid SMTP server probably isn't looking for your account's username and password, but rather your API key. The error seems to indicate your authentication is not successful.
https://sendgrid.com/docs/for-developers/sending-email/v3-csharp-code-example/
To integrate with SendGrids SMTP API:
Create an API Key with at least "Mail" permissions.
Set the server host in your email client or application to smtp.sendgrid.net.
This setting is sometimes referred to as the external SMTP server or the SMTP relay.
Set your username to apikey.
Set your password to the API key generated in step 1.
Set the port to 587.
Using the SendGrid C# library will also simplify this process:
https://sendgrid.com/docs/for-developers/sending-email/v3-csharp-code-example/
// using SendGrid's C# Library
// https://github.com/sendgrid/sendgrid-csharp
using SendGrid;
using SendGrid.Helpers.Mail;
using System;
using System.Threading.Tasks;
namespace Example
{
internal class Example
{
private static void Main()
{
Execute().Wait();
}
static async Task Execute()
{
var apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY");
var client = new SendGridClient(apiKey);
var from = new EmailAddress("test#example.com", "Example User");
var subject = "Sending with SendGrid is Fun";
var to = new EmailAddress("test#example.com", "Example User");
var plainTextContent = "and easy to do anywhere, even with C#";
var htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var response = await client.SendEmailAsync(msg);
}
}
}
I have a problem trying to send email (gmail) it won't allow me to send email if I didn't have the 'allow less secure app' turned on. What am I doin wrong?
try
{
smtpClient.Host = mServer;
smtpClient.Port = mPort;
smtpClient.EnableSsl = isenableSsl;
//Input new time out
if (mTimeout > 0)
{
smtpClient.Timeout = mTimeout;
}
//Check Authentication Mode
if (isAuthentication)
{
//Create Network Credentail if SMTP Server Turn On Authentication Mode
NetworkCredential credentials = new NetworkCredential();
credentials.UserName = mUserName;
credentials.Password = mPassword;
smtpClient.Credentials = credentials;
smtpClient.UseDefaultCredentials = false;
}
else
{
smtpClient.UseDefaultCredentials = true;
}
//Configuration Mail Information
if (string.IsNullOrEmpty(mDisplay)) mailMessage.From = new MailAddress(mFrom);
else mailMessage.From = new MailAddress(mFrom, mDisplay);
mailMessage.Sender = new MailAddress(mFrom);
mailMessage.ReplyTo = new MailAddress(mFrom);
//Set To Email Information
if (ToEmails.Count != 0)
{
mailMessage.To.Clear();
foreach (string mail in ToEmails)
{
mailMessage.To.Add(mail);
}
}
//Set Cc Email Information
mailMessage.CC.Clear();
foreach (string mail in CcEmails)
{
mailMessage.CC.Add(mail);
}
//Set Bcc Email Information
mailMessage.Bcc.Clear();
foreach (string mail in BccEmails)
{
mailMessage.Bcc.Add(mail);
}
//Set Mail Information
mailMessage.Subject = mSubject;
mailMessage.Body = mBody;
//Configuration Mail Option
mailMessage.IsBodyHtml = isBodyHtml;
mailMessage.SubjectEncoding = mSubjectEncoding;
mailMessage.BodyEncoding = mBodyEncoding;
mailMessage.Priority = mPriority;
mailMessage.DeliveryNotificationOptions = mDeliveryNotificationOptions;
//Clear Attachment File
mailMessage.Attachments.Clear();
//Add Attachments Internal File
AddAttachImage(ref mailMessage);
//Add Attachments External File
if (attachmentFiles.Count > 0)
{
AddAttachFile(ref mailMessage);
}
//Link Event Handler
smtpClient.SendCompleted += new SendCompletedEventHandler(smtpClient_SendCompleted);
//Send Message Fuction
SetLogfileSendEmail(smtpClient, mailMessage);
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{ return true; };
smtpClient.Send(mailMessage);
}
catch (Exception ex)
{
strInformation.Append("(Error) Method smtpClient_SendCompleted : " + ex.Message);
WriteLogFile();
throw new Exception("SMTP Exception: " + ex.Message);
}
}
It is also giving me this
SMTP Exception: The SMTP server requires a secure connection or the client was not authenticated.
The server response was: 5.7.0 Authentication Required.
I want to be able to send email without having to turn on the "allow less secure app" option on gmail account.
Is there any other way for third party apps to send emails without having to do 'allow less secure apps' ??
If you (sender) use gmail provider, try to activate this option
https://www.google.com/settings/security/lesssecureapps
I have tried many times to make an email app using gmail.
I am truly desperate, I have visited the entire Internet even in other languages but I found nothing.
How can I make a email web app in Asp.net c# using gmail?
This is the last code I applied.
try
{
MailMessage ms = new MailMessage();
ms.From = new MailAddress("myemail#gmail.com");
ms.To.Add("fillocj#hotmail.it");
ms.Body = txtTexto.Text;
ms.IsBodyHtml = true;
SmtpClient sm = new SmtpClient();
sm.Host = "smtp.gmail.com";
NetworkCredential nt = new NetworkCredential();
nt.UserName = "myemail#gmail.com";
nt.Password = "myPassword";
sm.UseDefaultCredentials = true;
sm.Credentials = nt;
sm.Port = 465;
sm.EnableSsl = true;
sm.Send(ms);
LabelError.Text = "Sent";
}
catch
{
LabelError.Text = "Error";
}
I always fail over and over again.
I tried with port: 25, also with 465 and 587. But any of them works fine. I do not know what the problem is.
Please help with this issue.
You also might have to configure your gmail account to allow "less secure apps".
See here: https://support.google.com/accounts/answer/6010255?hl=en
I had the same issues using an ASP.NET program to send e-mail via Gmail and it did not work until I did this.
This works on my computer using my email and login credentials for that email. If this doesn't work on yours, it is possible that it is a networking issue as indicated in the comment above.
MailMessage mM = new MailMessage();
mM.From = new MailAddress("myemail#gmail.com");
mM.To.Add("youremail#gmail.com");
mM.Subject = "your subject line will go here";
mM.Body = "Body of the email";
mM.IsBodyHtml = true;
SmtpClient sC = new SmtpClient("smtp.gmail.com") {Port = 587, Credentials = new NetworkCredential("myemail#gmail.com", "password"), EnableSsl = true};
sC.Send(mM);
Download Google.Apis.Gmail.v1 in nuget.
Create a project in https://console.developers.google.com/.
Inside your project navigate to Apis & auth > Apis (enable gmail api)
Navigate to Apis & auth > Credentials (create new client id)
Then copy your client id and client secret.
Here's the code in sending email using Gmail Api.
public class Gmail
{
public Gmail(ClientSecrets secrets, string appName)
{
applicationName = appName;
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(secrets,
new[] { GmailService.Scope.MailGoogleCom, GmailService.Scope.GmailCompose, GmailService.Scope.GmailReadonly },
"user", CancellationToken.None).Result;
service = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = applicationName,
});
}
public void SendEmail(System.Net.Mail.MailMessage mail)
{
var mimeMessage = MimeKit.MimeMessage.CreateFromMailMessage(mail);
Message msg = new Message()
{
Raw = Base64UrlEncode(mimeMessage.ToString())
};
SendMessage(service, msg);
}
private Message SendMessage(GmailService service, Message msg)
{
try
{
return service.Users.Messages.Send(msg, userid).Execute();
}
catch (Exception ex)
{
throw ex;
}
}
private string Base64UrlEncode(string input)
{
var inputBytes = System.Text.Encoding.UTF8.GetBytes(input);
// Special "url-safe" base64 encode.
return Convert.ToBase64String(inputBytes)
.Replace('+', '-')
.Replace('/', '_')
.Replace("=", "");
}
}
UPDATE:
In your controller:
public ActionResult SendEmail()
{
MailMessage msg = new MailMessage()
{
Subject = "Your Subject",
Body = "<html><body><table border='1'><tr>Hello, World, from Gmail API!<td></td></tr></table></html></body>",
From = new MailAddress("from#email.com")
};
msg.To.Add(new MailAddress("to#email.com"));
msg.ReplyToList.Add(new MailAddress("to#email.com")); // important! if no ReplyTo email will bounce back to the sender.
Gmail gmail = new Gmail(new ClientSecrets() { ClientId = "client_id", ClientSecret = "client_secret" }, "your project name");
gmail.SendEmail(msg);
}
I try two application, one in java and one in C#. The java application can send email successfully but the C# cannot. Here is the two apps :
1.Java
final String username = "myaccount#mydomain";
final String password = "mypassword";
String smtpHost = "smtp.mydomain";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {
#Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(username));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(username));
message.setSubject("Test send email");
message.setText("Hi you!");
Transport.send(message);
2.C#
string username = "myaccount#mydomain";
string password = "mypassword";
string smtpHost = "smtp.mydomain";
SmtpClient mailClient = new SmtpClient(smtpHost, 465);
mailClient.Host = smtpHost;
mailClient.Credentials = new NetworkCredential(username, password);
mailClient.EnableSsl = true;
MailMessage message = new MailMessage(username, username, "test send email", "hi u");
mailClient.Send(message);
So, what is the mistake i made in C# application? Why it cannot send email?
EDIT:
I have read this question How can I send emails through SSL SMTP with the .NET Framework? and it works. The deprecated System.Web.Mail.SmtpMail works but System.Net.Mail.SmtpClient doesn't. Why ?
3.This C# code work fine :
System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver","smtp.mydomain");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport","465");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing","2");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "myaccount#mydomain");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "mypassword");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
myMail.From = "myaccount#mydomain";
myMail.To = "myaccount#mydomain";
myMail.Subject = "new code";
myMail.BodyFormat = System.Web.Mail.MailFormat.Html;
myMail.Body = "new body";
System.Web.Mail.SmtpMail.SmtpServer = "smtp.mydomain:465";
System.Web.Mail.SmtpMail.Send(myMail);
The .NET System.Net.Mail.SmtpClient class cannot handle implicit SSL connection. Implicit SSL connections are sent over Port 465, as the client is configured in your example.
You can use a third party library like AIM (Aegis Implicit Mail) to send implicit SSL messages.
You can try this code as well. Also sends the email in a seperate thread.
using System.Net.Mail;
public static void Email(string Content, string To, string Subject, List<string> Attach = null, string User = "sender#sender.com", string Password = "MyPassword", string Host = "mail.sender.com", ushort Port = 587, bool SSL = false)
{
var Task = new System.Threading.Tasks.Task(() =>
{
try
{
MailMessage Mail = new MailMessage();
Mail.From = new MailAddress(User);
Mail.To.Add(To);
Mail.Subject = Subject;
Mail.Body = Content;
if (null != Attach) Attach.ForEach(x => Mail.Attachments.Add(new System.Net.Mail.Attachment(x)));
SmtpClient Server = new SmtpClient(Host);
Server.Port = Port;
Server.Credentials = new System.Net.NetworkCredential(User, Password);
Server.EnableSsl = SSL;
Server.Send(Mail);
}
catch (Exception e)
{
MessageBox.Show("Email send failed.");
}
});
Task.Start();
}
I am using mail message class to send an email. But if i check my Gmail account, mail is received as separate mail. I want mails in a single thread. I am also using the same subject and tried appending "Re: " before subject. it did not work for me.
I will be pleased if get the solution. following is the code I am using.
public static bool SendEmail(
string pGmailEmail,
string pGmailPassword,
string pTo,
string pFrom,
string pSubject,
string pBody,
System.Web.Mail.MailFormat pFormat,
string pAttachmentPath)
{
try
{
System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
myMail.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/smtpserver",
"smtp.gmail.com");
myMail.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
"465");
myMail.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendusing",
"2");
//sendusing: cdoSendUsingPort, value 2, for sending the message using
//the network.
//smtpauthenticate: Specifies the mechanism used when authenticating
//to an SMTP
//service over the network. Possible values are:
//- cdoAnonymous, value 0. Do not authenticate.
//- cdoBasic, value 1. Use basic clear-text authentication.
//When using this option you have to provide the user name and password
//through the sendusername and sendpassword fields.
//- cdoNTLM, value 2. The current process security context is used to
// authenticate with the service.
myMail.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//Use 0 for anonymous
myMail.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendusername",
pGmailEmail);
myMail.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendpassword",
pGmailPassword);
myMail.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/smtpusessl",
"true");
myMail.From = pFrom;
myMail.To = pTo;
myMail.Subject = pSubject;
myMail.BodyFormat = pFormat;
myMail.Body = pBody;
if (pAttachmentPath.Trim() != "")
{
MailAttachment MyAttachment =
new MailAttachment(pAttachmentPath);
myMail.Attachments.Add(MyAttachment);
myMail.Priority = System.Web.Mail.MailPriority.High;
}
// System.Web.Mail.SmtpMail.SmtpServer = CCConstants.MAIL_SERVER;
System.Web.Mail.SmtpMail.Send(myMail);
return true;
}
catch
{
throw;
}
}
you should know thread starter email internal ID, then you should send it back via headers "In-Reply-To: " or "References: ".
Btw sending email via gmail is rather simple:
var smtpClient = new SmtpClient("smtp.gmail.com",587);
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new NetworkCredential("USERNAME#gmail.com"
,"PASSWORD");
using (MailMessage message = new MailMessage("USERNAME#gmail.com","USERNAME#gmail.com"))
{
message.Subject = "test";
smtpClient.Send(message);
}
using (MailMessage message = new MailMessage("USERNAME#gmail.com","USERNAME#gmail.com"))
{
message.Subject = "Re: test";
message.Headers.Add("In-Reply-To", "<MESSAGEID.From.Original.Message>");
message.Headers.Add("References", "<MESSAGEID.From.Original.Message>");
smtpClient.Send(message);
}