我需要在自定义应用程序中使用 EWS/Exchange.asmx 设置从共享邮箱发送电子邮件,但不知道如何传递用户名和密码。
展望 356
共享邮箱:shared@outlook.com
用户地址:user@outlook.com(具有许可证和完全访问权限 共享...我可以使用网络客户端登录共享)
要在应用程序中输入的参数是:
如何填写用户名以使用用户密码登录共享?我尝试了一些组合,如:user@outlook.com\shared 等,但它不起作用(未经授权的错误)。当我只输入用户名并通过电子邮件正确发送时,但我需要从共享邮箱地址发送消息。
有什么想法吗?
答案 0 :(得分:0)
使用“user@outlook.com\shared@outlook.com”作为用户名。您可以使用 POP3 或 IMAP。这是一个使用 OpenPop 包的示例:
private string hostname = "pop-mail.outlook.com";
private int port = 995;
private bool useSsl = true;
private string username = "user@outlook.com\\shared@outlook.com";
private string password = "YourPassword";
public List<Message> FetchAllMessages()
{
// The client disconnects from the server when being disposed
using(Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
// Authenticate ourselves towards the server
client.Authenticate(username, password);
// Get the number of messages in the inbox
int messageCount = client.GetMessageCount();
// We want to download all messages
List<Message> allMessages = new List<Message>(messageCount);