使用.net在Outlook中发送文本消息

时间:2014-01-02 19:20:54

标签: .net email text outlook

这是我第一次在这里提出问题,如果有什么不清楚的话,请道歉。

我正在使用.net应用程序来阅读和发送带有Outlook的电子邮件。这是使用Outlook对象库完成的,代码如下:

Private Sub SendEmail(ByVal Message As String, ByVal EmailAddress As String)
    Dim objOutlook As Object
    Dim objOutlookMsg As Object
    objOutlook = CreateObject("Outlook.Application")
    objOutlookMsg = objOutlook.CreateItem(0)
        With objOutlookMsg
            .To = EmailAddress
            .Subject = "Subject"
            .Body = Message
            .Send()
        End With
        objOutlookMsg = Nothing
        objOutlook = Nothing
End Sub

Outlook 2010支持发送短信。我已经设置了这个,我可以从Outlook应用程序手动发送短信。我的问题是如何调整上面的代码来发送短信而不是电子邮件? Createitem数组没有“文本消息”对象,我在其他地方找不到任何示例。任何帮助或指示将非常感谢!

强尼

1 个答案:

答案 0 :(得分:0)

以下内容应该有效:

With objOulookMsg
    .To = EmailAddress
    .Recipients.ResolveAll()
    .Subject = "Subject"
    ' .BodyFormat = outlook.OlBodyFormat.olFormatPlain 
    ' symbolic constant olFormatPlain not known without Outlook project reference!
    .BodyFormat = 1    
    .Body = Message
End With

查看herehere以获取更详细的说明以及如何使用对Outlook的VB项目项目引用。

属性BodyFormat定义邮件项的格式。属性Body用于文本格式。但HTMLRichText邮件还会在属性Body中保留邮件的文本表示。

如果您通过Microsoft.Office.Interop.Outlook Project Menu, Add Reference COM Type Libary(假设Outlook 2010)添加对Microsoft Outlook 14.0 Object Library的引用,然后在代码顶部添加以下行

Imports outlook = Microsoft.Office.Interop.Outlook

Visual Basic将“知道”所有Outlook类,属性,方法和常量,并允许您使用Intellisense访问和使用所有内容。

相关问题