【问题标题】:Getting an exception error with my vb.net code我的 vb.net 代码出现异常错误
【发布时间】:2017-12-19 01:23:44
【问题描述】:

收到 $exception 错误“”未找到类型“选择”的公共成员“文本”。”我正在使用 Visual Studio,并尝试在单击按钮时创建表单,它将从打开的 Outlook 电子邮件中抓取文本. 调用 emailbody.Text 时出错。我对 Visual Basic 很陌生,所以请放轻松,哈哈。任何帮助都非常感谢。

 Private Sub Pull_info_Click(sender As Object, e As EventArgs) Handles Pull_info.Click
    Dim myOlApp As Outlook.Application = New Outlook.Application
    Dim myOlExp As Outlook.Explorer = myOlApp.ActiveExplorer
    Dim myOlSel As Outlook.Selection = myOlExp.Selection
    'Dim oMail As Outlook.MailItem
    Dim emailbody As Object

    emailbody = myOlSel

    Dim regex As Regex = New Regex("Ticket\sNumber:\s(.*?)\s-")
    Dim match As Match = regex.Match(emailbody.Text)
    If match.Success Then
        MsgBox(match.Value)
    End If
End Sub

【问题讨论】:

    标签: .net vb.net visual-studio


    【解决方案1】:

    选择对象似乎没有文本属性:https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.selection_members(v=office.14).aspx

    您可以使用调试器并查看哪些属性/值组合可供您使用,但我链接到的文档也有帮助。您还可以查看 ToString() 而不是 Text 返回的内容,也许它会为您提供所需的内容。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多