【发布时间】:2015-05-14 10:37:23
【问题描述】:
我不是 VB.Net Office Add in 的开发人员
我正在尝试为我的小团队开发一个小添加
我面临的问题是当我打开 MAIL(邮件项目)时,我能够从网站添加我想要的数据 现在,当我关闭邮件时,它会显示 您是否要保存此邮件等,
我怎样才能把原来的邮件替换回原来的邮件,这样那个窗口就不会出现了
或者如何丢弃消息“你想保存这封电子邮件吗..”
到这里为止我写的东西
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
请帮帮我
编辑
我不希望显示此消息,请有人指导我更正代码
【问题讨论】:
标签: vb.net visual-studio-2010 email outlook