Đã lâu rồi tôi không thích điều tương tự, và tôi kết luận rằng điều đó là không thể, mặc dù có quyền "Gửi dưới dạng".
Mạo danh là con đường duy nhất để đi với EWS, xem MSDN:
ExchangeService service = new ExchangeService();
service.UseDefaultCredentials = true;
service.AutodiscoverUrl("[email protected]");
// impersonate user e.g. by specifying an SMTP address:
service.ImpersonatedUserId = new ImpersonatedUserId(
ConnectingIdType.SmtpAddress, "[email protected]");
Nếu mạo danh không được kích hoạt, bạn sẽ phải cung cấp các thông tin của người dùng trên danh nghĩa của người mà bạn muốn hành động . Xem this MSDN article.
ExchangeService service = new ExchangeService();
service.Credentials = new NetworkCredential("user", "password", "domain");
service.AutodiscoverUrl("[email protected]");
Hoặc bạn có thể chỉ cần chỉ định reply-to address.
EmailMessage mail = new EmailMessage(service);
mail.ReplyTo.Add("[email protected]");
Tuy nhiên, "Gởi như" quyền làm áp dụng khi gửi thư sử dụng System.Net.Mail, mà trong nhiều trường hợp sẽ làm tốt khi chỉ gửi e-mail. Có tons of examples minh họa how to do this.
// create new e-mail
MailMessage mail = new MailMessage();
mail.From = new MailAddress("[email protected]");
mail.To.Add(new MailAdress("[email protected]"));
message.Subject = "Subject of e-mail";
message.Body = "Content of e-mail";
// send through SMTP server as specified in the config file
SmtpClient client = new SmtpClient();
client.Send(mail);
mail.ReplyTo sẽ không hoạt động, không có setter về vấn đề này. Email công cộngĐịa chỉThu hồi trả lờiĐể {get; } – RobDigital
Phải, đó là một bộ sưu tập. Vì vậy, bạn sẽ cần phải làm 'mail.ReplyTo.Add (" [email protected] ")' - Tôi sẽ sửa ví dụ trên. – bernhof
Sử dụng Mạo danh Tôi gặp lỗi trên mail.send. - Địa chỉ SMTP chính phải được chỉ định khi tham chiếu hộp thư – markthewizard1234