📄 form1.vb
字号:
Imports System.Runtime.InteropServices
Imports System.ComponentModel
Public Class Form1
Implements IMAPIAdviseSink
Private session As IMAPISession
Private connection As Integer
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim psession As IntPtr
Dim hresult As Integer = NativeMethods.MAPIInitialize(IntPtr.Zero)
hresult = NativeMethods.MAPILogonEx(0, Nothing, Nothing, 0, psession)
Me.session = CType(InTheHand.Runtime.InteropServices.Marshal2.GetTypedObjectForIUnknown(psession, GetType(IMAPISession)), IMAPISession)
Me.session.Advise(0, Nothing, fnev.ObjectCreated, Me, Me.connection)
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As CancelEventArgs) Handles Me.Closing
Me.session.Unadvise(Me.connection)
NativeMethods.MAPIUninitialize()
End Sub
Private Sub OnNotify(ByVal cNotif As UInteger, ByRef lpNotifications As NOTIFICATION) Implements IMAPIAdviseSink.OnNotify
If (lpNotifications.ulEventType = fnev.ObjectCreated) Then
Dim entryid As Byte() = New Byte(lpNotifications.newmail.cbEntryID - 1) {}
Marshal.Copy(lpNotifications.newmail.lpEntryID, entryid, 0, entryid.Length)
Media.SystemSounds.Asterisk.Play()
NativeMethods.MailDisplayMessage(entryid, entryid.Length)
End If
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Me.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -