System.NullReferenceException was unhandled Message: An unhandled exception of type 'System.NullReferenceException' occurred in Microsoft.Threading.Tasks.dll Additional information: Object reference not set to an instance of an object.
public void SendEmail() { string emailTo = string.Empty; string emailFrom = string.Empty; string subject = string.Empty; string text = string.Empty; string html = string.Empty; string userName = string.Empty; string password = string.Empty; // Create the email object first, then add the properties. SendGridMessage myMessage = new SendGridMessage(); myMessage.AddTo("test@gmail.com "); myMessage.From = new MailAddress("test@gmail.com", "User I am"); myMessage.Subject = "Testing the SendGrid Library"; myMessage.Text = "Hello World!"; myMessage.Html = ""; // Create credentials, specifying your user name and password. var credentials = new NetworkCredential("myUserName", "myPassword"); // Create an Web transport for sending email, using credentials... var transportWeb = new Web(credentials); // Send the email. transportWeb.DeliverAsync(myMessage); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)