コード例 #1
0
        public virtual List <IMailResponse> Send(MailAttributes mailAttributes)
        {
            var mail     = GenerateProspectiveMailMessage(mailAttributes);
            var response = new List <IMailResponse>();


            List <EmailResult> resp = null;

            var completeEvent = new ManualResetEvent(false);

            ThreadPool.QueueUserWorkItem((obj) =>
            {
                resp = client.SendMessage(new SendMessageRequest(mail)).Result;
                completeEvent.Set();
            });

            completeEvent.WaitOne();

            response.AddRange(resp.Select(result => new MandrillMailResponse
            {
                Email        = result.Email,
                Status       = MandrillMailResponse.GetProspectiveStatus(result.Status.ToString()),
                RejectReason = result.RejectReason,
                Id           = result.Id
            }));

            return(response);
        }
コード例 #2
0
        public virtual async Task <List <IMailResponse> > SendAsync(MailAttributes mailAttributes)
        {
            var mail     = GenerateProspectiveMailMessage(mailAttributes);
            var response = new List <IMailResponse>();

            await _client.SendMessageAsync(mail).ContinueWith(x => response.AddRange(x.Result.Select(result => new MandrillMailResponse
            {
                Email        = result.Email,
                Status       = MandrillMailResponse.GetProspectiveStatus(result.Status.ToString()),
                RejectReason = result.RejectReason,
                Id           = result.Id
            })));

            return(response);
        }
コード例 #3
0
        public virtual List <IMailResponse> Send(MailAttributes mailAttributes)
        {
            var mail     = GenerateProspectiveMailMessage(mailAttributes);
            var response = new List <IMailResponse>();

            var resp = _client.SendMessage(mail);

            response.AddRange(resp.Select(result => new MandrillMailResponse
            {
                Email        = result.Email,
                Status       = MandrillMailResponse.GetProspectiveStatus(result.Status.ToString()),
                RejectReason = result.RejectReason,
                Id           = result.Id
            }));

            return(response);
        }