VB.Net Outlook 2010添加如何收听检查员关闭事件(邮件项目) [英] VB.Net Outlook 2010 Add in How to Listen To Inspector Close Event (Mail Item)

查看:560
本文介绍了VB.Net Outlook 2010添加如何收听检查员关闭事件(邮件项目)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是VB.Net Office中的开发人员添加



我正在为我的小团队开发一个小的添加



我正在面对的问题是当我打开邮件(邮件ITEM)时,我可以从网站添加我所需的数据
现在,当我关闭邮件时,它说你要保存此消息等,



如何替换回原始邮件,以便该窗口不会来



或如何舍弃消息您要保存此电子邮件..



这里直到现在我写的是

 导入System.Runtime.InteropServices 
导入System.Text.RegularExpressions

公共类ThisAddIn
Dim WithEvents inspectors As Outlook.Inspectors
Dim WithEvents currentExplorer As Outlook.Explorer = Nothing
Public WithEvents myItem As Outlook.MailItem

Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System .EventArgs)处理Me.Startup
inspectors = Me.Application.Inspectors
End Sub

Private Sub ThisAddIn_Shutdown()处理Me.Shutdown
MsgBox(Yo ,MsgBoxStyle.Information)
End Sub

Private Sub inspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector)处理inspectors.NewInspector
Dim mailItem As Outlook.MailItem = TryCast(Inspector.CurrentItem,Outlook.MailItem)
Dim mBody As String = mailItem.Body
Dim mFrom As String = GetSmtpAddress(mailItem).ToString()
Dim cec As String
Dim result As String
Dim itm As Object
'itm = Inspector.CurrentItem
Dim webClient As New System.Net.WebClient

如果mFrom IsNot Nothing Then
cec = mFrom.Split(New Char(){@c})(0)
result = webClient.DownloadString(http://example.com/post.php?submit=1& ; name =&a熔点; cec)
Dim oAddin As new jsonparser(result)

如果不是(mailItem不是)然后
如果(mailItem.EntryID IsNot Nothing)然后
如果(oAddin .GetProperty(team)。值IsNot不存在OrElse oAddin.GetProperty(team)。值IsNot你不能直接访问)然后
mailItem.Body =[& oAddin.GetProperty(team)。Value.ToString()& ]& vbCrLf& vbCrLf& vbCrLf& mBody
MsgBox(mailItem.Body)
End If
End If
End If
End If

Dim myOlInspectorClose = inspectors
'Dim myOlInspectorClose As Outlook.Inspectors
End Sub

Private Sub myOlInspectorClose_Close()
MsgBox(hey clsing)
End Sub

私有函数GetSmtpAddress2010(ByVal mItem As Outlook.MailItem)
返回mItem.Sender.GetExchangeUser()。PrimarySmtpAddress
结束函数

私有函数GetSmtpAddress(ByVal mItem As Outlook。 MailItem)
'Dim mItem As Outlook.MailItem
Dim recip As Outlook.Recipient
Dim exUser As Outlook.ExchangeUser
Dim sAddress As String

如果(mItem.SenderEmailType.ToLower()=ex)然后
recip = Globals.ThisAddIn.Application.GetNamespace(MAPI)。CreateRecipient(mItem.Sende rEmailAddress)
exUser = recip.AddressEntry.GetExchangeUser()
sAddress = exUser.PrimarySmtpAddress
Else
sAddress = mItem.SenderEmailAddress.Replace(',)
结束如果

返回sAddress
结束函数
结束类

请帮助我



编辑



请看这里见这里http://i59.tinypic.com/j6u74l.png



我不希望这个消息被显示出来,有些人可以指示我修正代码。

解决方案


我正在面对的问题是当我打开邮件(邮件ITEM)时,我可以从网站添加我所需的数据现在当我关闭邮件时,它表示您要保存此邮件等。


您需要调用保存方法将Microsoft Outlook项目保存到当前文件夹,如果是新项目,则将其保存到Outlook默认文件夹的项目类型。



此外,我建议立即释放所有底层的COM对象。使用 System.Runtime.InteropServices.Marshal.ReleaseComObject 在您完成使用Outlook时释放Outlook对象。然后在Visual Basic(C#中的null)中将变量设置为Nothing,以释放对该对象的引用。您可以在系统地发布对象文章。


I am not a developer in VB.Net Office Add in

I was trying to Develop a Small Adding for my Small Team

The problem i am Facing is When i open the MAIL (Mail ITEM) I am able to Add my Desired Data from a website Now when i Close the Mail it says Do you want to Save this Message etc.,

How can i replace Back the original Mail so that that window doesn't come

Or how to Discard the Message "Do you want to Save this email.."

Here Till now what i have written

Imports System.Runtime.InteropServices
Imports System.Text.RegularExpressions

Public Class ThisAddIn
    Dim WithEvents inspectors As Outlook.Inspectors
    Dim WithEvents currentExplorer As Outlook.Explorer = Nothing
    Public WithEvents myItem As Outlook.MailItem

    Private Sub ThisAddIn_Startup(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles Me.Startup
        inspectors = Me.Application.Inspectors
    End Sub

    Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
        MsgBox("Yo", MsgBoxStyle.Information)
    End Sub

    Private Sub inspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles inspectors.NewInspector
        Dim mailItem As Outlook.MailItem = TryCast(Inspector.CurrentItem, Outlook.MailItem)
        Dim mBody As String = mailItem.Body
        Dim mFrom As String = GetSmtpAddress(mailItem).ToString()
        Dim cec As String
        Dim result As String
        Dim itm As Object
        'itm = Inspector.CurrentItem
        Dim webClient As New System.Net.WebClient

        If mFrom IsNot Nothing Then
            cec = mFrom.Split(New Char() {"@"c})(0)
            result = webClient.DownloadString("http://example.com/post.php?submit=1&name=" & cec)
            Dim oAddin As New jsonparser(result)

            If Not (mailItem Is Nothing) Then
                If (mailItem.EntryID IsNot Nothing) Then
                    If (oAddin.GetProperty("team").Value IsNot "Doesn't Exists" OrElse oAddin.GetProperty("team").Value IsNot "You cannot access directly") Then
                        mailItem.Body = "[" & oAddin.GetProperty("team").Value.ToString() & "]" & vbCrLf & vbCrLf & vbCrLf & mBody
                        MsgBox(mailItem.Body)
                    End If
                End If
            End If
        End If

        Dim myOlInspectorClose = inspectors
        'Dim myOlInspectorClose As Outlook.Inspectors
    End Sub

    Private Sub myOlInspectorClose_Close()
        MsgBox("hey clsing")
    End Sub

    Private Function GetSmtpAddress2010(ByVal mItem As Outlook.MailItem)
        Return mItem.Sender.GetExchangeUser().PrimarySmtpAddress
    End Function

    Private Function GetSmtpAddress(ByVal mItem As Outlook.MailItem)
        'Dim mItem As Outlook.MailItem
        Dim recip As Outlook.Recipient
        Dim exUser As Outlook.ExchangeUser
        Dim sAddress As String

        If (mItem.SenderEmailType.ToLower() = "ex") Then
            recip = Globals.ThisAddIn.Application.GetNamespace("MAPI").CreateRecipient(mItem.SenderEmailAddress)
            exUser = recip.AddressEntry.GetExchangeUser()
            sAddress = exUser.PrimarySmtpAddress
        Else
            sAddress = mItem.SenderEmailAddress.Replace("'", "")
        End If

        Return sAddress
    End Function
End Class

Please Help me

EDIT

Please see here see here http://i59.tinypic.com/j6u74l.png

I don't want this message to be displayed can some one direct me to correct code please

解决方案

The problem i am Facing is When i open the MAIL (Mail ITEM) I am able to Add my Desired Data from a website Now when i Close the Mail it says Do you want to Save this Message etc.,

You need to call the Save method which saves the Microsoft Outlook item to the current folder or, if this is a new item, to the Outlook default folder for the item type.

Also I'd recommend releasing all underlying COM objects instantly. Use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. You can read more about that in the Systematically Releasing Objects article.

这篇关于VB.Net Outlook 2010添加如何收听检查员关闭事件(邮件项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆