使用我的vb.net代码

时间:2017-12-19 01:23:45

标签: .net vb.net visual-studio

获取$异常错误""公共成员'文字'在类型'选择'没找到。"我正在使用visual studio并尝试在单击按钮时制作表单,它将从打开的Outlook电子邮件中删除文本。调用emailbody.Text时发出错误。我对视觉基础非常陌生,所以请对我很轻松。任何帮助都将非常感谢。

 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

1 个答案:

答案 0 :(得分:0)

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

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