简体   繁体   English

为通过Office 365发送的邮件设置不同的发件人地址

[英]Setting different From address for mail send through Office 365

While sending mail using office 365 how can we set different from address. 在使用Office 365发送邮件时,我们如何设置与地址不同的地址。 Basically the credentials I am giving are for office 365 account/username and from email address I am mentioning the different account. 基本上,我提供的凭据是针对Office 365帐户/用户名的,从电子邮件地址中我提到的是其他帐户。 So this has to be same? 所以这必须一样吗?

Below is my code. 下面是我的代码。

MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress("toid@domain.com", "To Name"));
msg.From = new MailAddress("fromid@domain.com", "From Name");
msg.Subject = "Azure Web App Email using smtp.office365.com";
msg.Body = "Test message using smtp.office365.com on Azure from a Web App";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("o365id@domain.com", "O365 PASS");
client.Port = 587;
client.Host = "smtp.office365.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;

But it is giving me below error, 但这给了我下面的错误,

Mailbox unavailable. 信箱不可用。 The server response was: 5.7.60 SMTP; 服务器响应为:5.7.60 SMTP; Client does not have permissions to send as this sender 客户端无权发送此发送者

Basically I want to set the different from address while sending the mail. 基本上,我想在发送邮件时设置与地址不同的地址。

EDIT 1 : The from email address will be the logged in users email id. 编辑1 :发件人电子邮件地址将是登录用户的电子邮件ID。 This will be from same domain, but can we give the send as permission for common mailbox considering this. 这将来自相同的域,但是考虑到这一点,我们可以为普通邮箱授予“发送为”权限。

That error mean the credentials your trying to send with doesn't have the SendAS permission for the user/mailbox your trying to send as the Sender. 该错误意味着您尝试发送的凭据不具有您尝试作为发送方发送的用户/邮箱的SendAS权限。 To fix that you will either need to grant that through the Portal https://technet.microsoft.com/en-AU/library/jj919240%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396 or using PowerShell 要解决此问题,您将需要通过门户网站https://technet.microsoft.com/zh-CN/library/jj919240%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396授予该权限

Add-ADPermission -Identity helpdesksupport -User o365id@domain.com -ExtendedRights "Send As"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Office365 上使用默认 SMTP 凭据的异常 - 客户端未通过身份验证在 MAIL FROM 期间发送匿名邮件 - Exception using default SMTP credentials on Office365 - Client was not authenticated to send anonymous mail during MAIL FROM 使用与地址不同的地址发送邮件 - Send mail using different from address 通过 SmtpClient 和 smtp.office365.com 发送邮件将电子邮件的敏感度设置为正常、个人、私人或机密 - Sending mail through SmtpClient and smtp.office365.com setting email's sensitivity to normal, personal, private or confidential 如何或无法通过 Office 365 smtp 发送邮件 - how or Unable to send mail via office 365 smtp 使用 smtp.office365.com 发送邮件失败 - mail send using smtp.office365.com failed 如何通过指定发件人地址使用Microsoft.Office.Interop.Outlook.MailItem发送邮件 - How to send a mail using Microsoft.Office.Interop.Outlook.MailItem by specifying the From Address 使用Outlook 365发送邮件 - Send Mail with Outlook 365 无法使用 c# SmtpClient 从 Office 365 发送电子邮件 - Unable to send email from Office 365 using c# SmtpClient 从 Wcf Windows 服务发送 Office 365 电子邮件 - Send Office 365 email from Wcf Windows Service 通过 Exchange Online (Office 365) 使用 System.Net.Mail 发送 SMTP email - Send SMTP email using System.Net.Mail via Exchange Online (Office 365)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM