public void Consumer() { queueConsumer.Start(queueName, a => { using (var smtp = new SmtpClient()) { smtp.Host = "localhost"; smtp.Port = 1025; smtp.EnableSsl = false; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "password"); using (var mail = new MailMessage()) { mail.From = new MailAddress("*****@*****.**"); mail.To.Add(new MailAddress("*****@*****.**")); mail.CC.Add(new MailAddress("*****@*****.**")); mail.Subject = "File moved"; mail.Body = "File moved successfully. "; var task = Task.Run(async() => await smtp.SendMailAsync(mail)); Task.WaitAll(task); } } }); }