[英]Sending Mail from .NET C# using activesync
I cannot find any example in C# code (nor other languages and platforms) with send mail implementation. 我找不到带有发送邮件实现的C#代码(其他语言和平台)中的任何示例。 I managed to find and dl code example with provisioning and folder sync tasks, but cannot find send mail example.
我设法找到和dl带有配置和文件夹同步任务的代码示例 ,但是找不到发送邮件的示例。
This is all from MSDN: http://msdn.microsoft.com/en-us/library/ee202897(v=exchg.80).aspx 全部来自MSDN: http : //msdn.microsoft.com/zh-cn/library/ee202897 (v= exchg.80).aspx
BR, JDK BR,JDK
You could consider the Microsoft.Exchange.WebServices.dll. 您可以考虑使用Microsoft.Exchange.WebServices.dll。 Sorry the example below is a bit rough as it is a cut down version of a much bigger class I use.
抱歉,下面的示例有点粗糙,因为它是我使用的更大类的简化版本。
VB.NET: VB.NET:
Imports Microsoft.Exchange.WebServices.Data
Public Class Exchange
Public Sub SendEmail(fromEmailAddress As String, toEmailAddress As String, body As String, subject As String)
Dim exService = New ExchangeService(serverVersion)
exService.AutodiscoverUrl(fromEmailAddress)
Dim msg As New EmailMessage(exService)
msg.Subject = subject
msg.Body = body
msg.ToRecipients.Add(New Microsoft.Exchange.WebServices.Data.EmailAddress(toEmailAddress,toEmailAddress))
msg.SendAndSaveCopy()
End Sub
End Class
C# C#
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using Microsoft.Exchange.WebServices.Data;
public class Exchange
{
public void SendEmail(string fromEmailAddress, string toEmailAddress, string body, string subject)
{
dynamic exService = new ExchangeService(serverVersion);
exService.AutodiscoverUrl(fromEmailAddress);
EmailMessage msg = new EmailMessage(exService);
msg.Subject = subject;
msg.Body = body;
msg.ToRecipients.Add(new Microsoft.Exchange.WebServices.Data.EmailAddress(toEmailAddress, toEmailAddress));
msg.SendAndSaveCopy();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.