如何将visual basic .net与microsoft exchange与免费库连接?

时间:2011-03-03 02:16:27

标签: vb.net exchange-server mapi

VB.net是否有用于连接MS交换服务器的免费库? 我找到了一些有偿的,但我宁愿不投资,所以找不到任何免费的图书馆.. 我尝试使用java作为mapi的协议层,但它不起作用

2 个答案:

答案 0 :(得分:3)

你想要完成什么?

我使用常规SMTP客户端

通过我的Exchange帐户发送邮件没有问题
    Public Shared Sub SendEmail(ByVal sFromAddress As String, _
                            ByVal sToAddress As String, _
                            ByVal sSMTPAddress As String, _
                            ByVal sUsername As String, _
                            ByVal sPassword As String, _
                            ByVal sOrderNo As String, _
                            ByVal sURL As String, _
                            ByVal iPort As Integer)

    Try
        Dim client As New SmtpClient(sSMTPAddress, iPort)
        client.UseDefaultCredentials = False
        client.Credentials = New System.Net.NetworkCredential(sUsername, sPassword)
        client.EnableSsl = True

        Dim mail As New MailMessage
        mail.To.Add(sToAddress)
        mail.From = New MailAddress(sFromAddress)
        mail.Subject = GetSubject(sOrderNo)
        mail.IsBodyHtml = True
        mail.Body = GetBody(sOrderNo, sURL)

        client.Send(mail)

    Catch ex As Exception
        MessageBox.Show("Error Sending E-mail!")
    End Try

End Sub

如果您希望进行更有意义的互动,我知道您可以使用Microsoft.Office.Interop.Outlook完成很多工作。查看http://msdn.microsoft.com/en-us/library/ms268893(VS.80).aspx了解更多信息。

答案 1 :(得分:1)