Retrieve an individual delivery report (or combined reports), which shows the current known status of messages sent in a given time period, or for a particular campaign or campaigns.
Conversely, the function getDeliveryReports (page 18) gets a list of available delivery report names, including delivery reports for campaigns.
See also What is a sent message?
Note |
---|
E messages sent with the API can be given a 'tag'. The getDeliveryReport function allows you to specify that tag in order to restrict your search. |
To get the contents of a delivery report for the campaign name 'mycampaign-020411':
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
DeliveryReport[] reports = tmClient.getDeliveryReport("mycampaign-020411"); |
To get the delivery report details for 'mycampaign-020411' between 01:00 and 02:00 on 1st Jan 2011:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
DeliveryReport[] reports = tmClient.getDeliveryReport("mycampaign-020411", new DateTime(2011, 1, 1, 1, 0, 0), DateTime(2011, 1, 1, 2, 0, 0)); |
Or, between 01:00 on 1st Jan 2011 and now:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
DeliveryReport[] reports = tmClient.getDeliveryReport("mycampaign-020411", new DateTime(2011, 1, 1, 1, 0, 0), DateTime.Today); |
To get delivery report details for all campaigns and API sends between the same dates as the previous 2 examples:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
DeliveryReport[] reports = tmClient.getDeliveryReport("all", new DateTime(2011, 1, 1, 1, 0, 0), DateTime(2011, 1, 1, 2, 0, 0)); reports = tmClient.getDeliveryReport("all", new DateTime(2011, 1, 1, 1, 0, 0), DateTime.Today); |
To get a delivery report with the name 'mycampaign-020411', restricted to those messages sent with custom tag 'test':
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
DeliveryReport[] reports = tmClient.getDeliveryReport("mycampaign-020411", "test"); |
To get the status of messages from all delivery reports for messages sent with custom tag 'test':
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
DeliveryReport[] reports = tmClient.getDeliveryReport("all", "test"); |
The same as the previous 2 examples, but between 2 dates:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
DeliveryReport[] reports = tmClient.getDeliveryReport("all", "test", new DateTime(2011, 1, 1, 1, 0, 0), DateTime(2011, 1, 1, 2, 0, 0)); reports = tmClient.getDeliveryReport("all", "test", new DateTime(2011, 1, 1, 1, 0, 0), DateTime.Today); |
A complete example, including output:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
DeliveryReport[] reports = tmClient.getDeliveryReport("all"); foreach (DeliveryReport report in reports) { Console.WriteLine(report); foreach (Hashtable row in report.Rows) { Console.WriteLine("\tMessage ID: {0}", row["message_id"]); Console.WriteLine("\tLast Updated: {0}", row["last_updated"]); Console.WriteLine("\tMobile Number: {0}", row["mobile_number"]); Console.WriteLine("\tStatus: {0}", row["status"]); Console.WriteLine("\tCustom {0}", row["custom"]); } } |