Ejemplo n.º 1
0
        private static async Task <Response> SendTemplateEmail()
        {
            var requestmessage = new HttpRequestMessage(HttpMethod.Post, "https://api.sendgrid.com/v3/mail/send");

            requestmessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Apikey);
            requestmessage.Content = new StringContent(
                "{\n  " +
                "\"personalizations\": [\n    " +
                "{\n      " +
                "\"to\": [\n        " +
                "{\n          " +
                "\"email\": \"<<<<Insert Addressee email here>>>>\",\n          " + //Requires attention
                "\"name\": \"<<<<Insert Addressee name here>>>>\"\n        " +      //Requires attention
                "}\n      " +
                "],\n      " +
                "}\n  " +
                "],\n  " +
                "\"from\": {\n    " +
                "\"email\": \"<<<<Insert Sender email here>>>>\",\n    " +          //Requires attention
                "\"name\": \"<<<<Insert Sender name here>>>>\"\n  " +               //Requires attention
                "},\n  " +
                "\"template_id\": \"<<<<Insert Template ID here>>>>\"\n" +          //Requires attention
                "}",
                Encoding.UTF8,
                "application/json"
                );

            return(await Client.MakeRequest(requestmessage));
        }