简体   繁体   English

如何获取已发送 email 的事件并使用 c# 在 sendgrid 中打开、点击计数?

[英]How to get event of sent email & open, click counts in sendgrid using c#?

I used the sendgrid's filters to filter messages and get count of open & clicks.我使用 sendgrid 的过滤器来过滤消息并计算打开和点击次数。 But is there any other way to get that counts & events of sent email?但是还有其他方法可以获取发送 email 的计数和事件吗?

var queryParams ="(last_event_time BETWEEN TIMESTAMP " + "'" + lastEmailSent + "'" + " AND TIMESTAMP " + "'" + date2 + "'" + ") AND from_email='" + From_Email + "' AND subject='" + myMessage.Subject + "'";

var client1 = new RestClient("https://api.sendgrid.com/v3/messages?query="+ queryParams +"&limit=1");  
                var request = new RestRequest(Method.GET);  
                client1.Timeout = -1;

                // var request1 = new RestRequestExecute();
                request.AddHeader("X-Query-Id", "{{X-Query-Id}}");
                request.AddHeader("X-Cursor", "{{X-Cursor}}");
                request.AddHeader("Authorization", "Bearer API_KEY");
                
                IRestResponse response = client1.Execute(request);
                Console.WriteLine(response.Content);

Does anyone know how this could be done.有谁知道如何做到这一点。 Thanks.谢谢。

Twilio SendGrid developer evangelist here. Twilio SendGrid 开发人员在这里。

You can receive events like opens and clicks live using the Event Webhook .您可以使用Event Webhook实时接收打开和点击等事件。 There are 2 types of events - delivery and engagement events.有两种类型的事件 - 交付和参与事件。 Delivery events indicate the status of email delivery to the recipient.传递事件指示 email 传递给收件人的状态。 Engagement events indicate how the recipient is interacting with the email, such as opening or clicking on the email. Events are batched and then sent as an HTTP request to your designated endpoint and you can parse out the events that are important to you.参与事件表示收件人如何与 email 交互,例如打开或单击 email。事件被分批处理,然后作为 HTTP 请求发送到您指定的端点,您可以解析出对您重要的事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM