Ejemplo n.º 1
0
        public async Task <string> SendMail(EmailMsg message, Boolean isHtml)
        {
            msg.AddTo(message.Recipient);
            msg.Subject = message.Subject;
            if (isHtml)
            {
                msg.HtmlContent = message.Body;
            }
            else
            {
                msg.PlainTextContent = message.Body;
            }



            SendGrid.Response response = await client.SendEmailAsync(msg);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return("Message was sent successfully");
            }
            else
            {
                return(string.Empty);
            }
        }
Ejemplo n.º 2
0
        public void SendMail(EmailMsg message, Boolean isHtml, string fileName, Byte[] fileBytes)
        {
            msg.AddTo(message.Recipient);
            msg.Subject = message.Subject;

            if (!isHtml)
            {
                msg.PlainTextContent = message.Body;
            }
            else
            {
                msg.HtmlContent = message.Body;
            }
            if (!string.IsNullOrEmpty(fileName))
            {
                string fileContents = Convert.ToBase64String(fileBytes);
                msg.AddAttachment(fileName, fileContents);
            }

            client.SendEmailAsync(msg);
        }