Microsoft.Graph - 如何从具有不同用户名的共享邮箱发送? [英] Microsoft.Graph - How to send from shared email box with different user names?

查看:43
本文介绍了Microsoft.Graph - 如何从具有不同用户名的共享邮箱发送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将服务的代码从使用 SMTP 移植到 Office 365.

I am currently porting code for a service from using SMTP to Office 365.

使用 SMTP,我可以使用发件人"在来自共享收件箱的邮件上设置不同的用户名.字段,同时保留共享邮箱地址.这似乎不适用于 Office 365.

With SMTP I am able to set different user names on a mail from shared inbox using the "from" field, while retaining the shared email box address. This does not appear to be working via Office 365.

流程为:

  1. 客户填写发送到共享邮箱的网络表单
  2. 服务读取电子邮件,为该查询分配一个用户,并从共享框向客户发送一封确认电子邮件,但带有用户名
  3. 客户的任何回复都会返回到共享框以供进一步处理
  1. Customer fills in a web form that is sent to the shared email box
  2. The service reads the email, allocates a user to this inquiry and sends a confirmation email back to the customer from the shared box but with the user's name
  3. Any reply from the customer comes back to the shared box for further processing

使用 Microsoft.Graph API 我可以发送/接收电子邮件,但我无法将用户的姓名欺骗到来自共享邮箱的外发电子邮件,它始终(向收件人)显示为共享邮箱的名称.

Using the Microsoft.Graph API I can send / receive emails, but I can't spoof the user's name on to the outgoing email from the shared box, it always shows (to the recipient) as the name of the shared box.

代码如下:

try
{
    var sendMessage = new Message()
    {
        ToRecipients = new List<Recipient> { new Recipient()   
            { 
                EmailAddress = new EmailAddress() 
                { 
                    Address = "customer@customer-domain.com" 
                } 
            } 
        },

        From = new Recipient()
            {
                EmailAddress = new EmailAddress() 
                { 
                    Address = "shared-box@my-domain.com", 
                    Name = "ALLOCATED USER NAME HERE" 
                }
            },

        Subject = "Test Subject",
                 
        Body = new ItemBody()
            {
                ContentType = BodyType.Text,
                Content = "This is a test text body"
            },
                
            Attachments = attachments
        };

    await Client
        .Users[thisUser.Id]
            .SendMail(sendMessage).Request().PostAsync();
}
catch(Exception ex)
{
    Debug.WriteLine(ex);
}

Graph 似乎完全忽略了收件人姓名.

Graph seems to be ignoring the recipient name altogether.

Microsoft Graph 文档:自动创建、发送和处理消息 建议

Microsoft Graph doc : Automate creating, sending and processing messages suggests

如果 Exchange 管理员已将邮箱的 sendAs 权限分配给其他一些用户,则可以更改 from 属性.管理员可以通过在 Azure 门户中选择邮箱所有者的邮箱权限,或使用 Exchange 管理中心或 Windows PowerShell Add-ADPermission cmdlet 来执行此操作.然后,您可以以编程方式将 from 属性设置为对该邮箱具有 sendAs 权限的用户之一.

The from property can be changed if the Exchange administrator has assigned sendAs rights of the mailbox to some other users. The administrator can do this by selecting Mailbox Permissions of the mailbox owner in the Azure portal, or by using the Exchange Admin Center or a Windows PowerShell Add-ADPermission cmdlet. Then, you can programmatically set the from property to one of these users who have sendAs rights for that mailbox.

我已确认这些权限已在 Office 365 门户中设置.我还能缺少什么?

I have confirmed these permissions are set in the Office 365 portal. What else could I be missing?

推荐答案

我这边的类似问题,在微软文档中找到了答案 这里:它不起作用 - 它总是选择个人资料与电子邮件匹配的名称并将其用作友好名称.

Similar problem on my end, and found an answer in the microsoft docs here: It doesn't work - it always picks the profile name matching the e-mail and uses it for the friendly name.

因此,在您的情况下,您还必须更改发件人地址,而不仅仅是发件人名称.

So in your case you would have to change the from-address also, not only the from-name.

这篇关于Microsoft.Graph - 如何从具有不同用户名的共享邮箱发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆