Tommy Cawley
Tommy Cawley

Reputation: 185

Mandrill search email result

I am curious can I search the result of whether an email bounced or not using the mandill api in c# .net I know this can be acheived using webhooks but dont know how to do that. basically I want to search the result by supplying an email id and finding out whether it was a hard bounce or soft bounce or successful. if so please post the code. thanks, Tommy

Upvotes: 0

Views: 1939

Answers (2)

Vivekh
Vivekh

Reputation: 4259

I am afraid you cant do the search by mail id but there is an _Id which is related the mail being sent through the mandrill api send method.

enter image description here

and now with that id you can search the message details if you want details about particular mail

MandrillApi Api= new MandrillApi(key);
Info info = new Info();
info.key = key;
info.id = _Id;  // which is the id of the just sent mail
var list = Api.Info(info);

which will results this where you can see the state of message whether its being sent or bonced

enter image description here

or if you want to search entire messages and know the details of each message then you can come up with some thing like this

        Mandrill.Search search = new Mandrill.Search();
        search.senders = new string[] { "[email protected]" };
        search.key = key;
        MandrillApi Api= new MandrillApi(key);
        var searchs = Api.Search(search);

and then you can go through the individual message by looping it

foreach (var x in searchs)
        {

            Info info = new Info();
            info.key = key;
            info.id = x._id;
            try
            {
                var list = Api.Info(info);

            }
            catch (Exception exe)
            {

            }
        }

and not to forgot i have changed the api method's myself as i found that they are not working for me you can download the cs project Here add it as an existing project and can call the api methods

Upvotes: 0

Joshua Moore
Joshua Moore

Reputation: 24776

First, there are several c# wrappers available for Mandrill. Which one you want to use is up to you and how it fits your needs.

Second, of course there is a way to see if a message is hard bounced or soft bounced. The Mandrill API for Message info contains all the details regarding the status and bounce description.

Upvotes: 1

Related Questions