We have two mailboxes, one external mailbox 1 (outlook), and one internal mailbox 0 (lotus notes ). If you want outlook to determine the content of the subject after receiving a new mail, if it starts with "kkk:", send the content following "kkk:" to the mailbox of lotus notes.
Test Environment (xp + msft outlook), press alt + F11 to enter VBA editing. Be sure to set it to low in tools> macros> Security. Some code is as follows (manual copy may be incorrect ~~) :
Option explicit
Public WithEvents outApp as Outlook. Application
Sub Initialite_handle ()
Set outApp = Application
End Sub
'Called when OutLook is opened and application reference is registered
Private sub Application_Startup ()
Initialize_handle
End Sub
'Note the function name. It is automatically called when a new email is received.
Private sub outApp_NewMailEx (ByVal EntryIDCollection As String)
Dim mai As Object
Dim intInitial As Integer
Dim intFinal As Integer
Dim strEntry As String
Dim intLength As Integer
IntInitial-1
IntLength = Len (EntryIDCollection)
IntFinal = InStr (intInitial, EntryIDCollection ,",")
Do While intFinal <> 0
StrEntryID = Stringmid (EntryIDCollection, intInitial, (intFinal-intInitial ))
Set mai = Application. Session. GetItemFromID (strEntryID)
Newmail_proc mai
IntInitial = intFinal + 1
IntFinal = inStr (intInitial, EntryIDCollection ,",")
Loop
StrEntryID = String. mid (EntryIDCollection, intInitial, (intLength-intInitial) + 1)
Set mai = Application. Session. GetItemFromID (strEntryID)
Newmail_proc mai
End Sub
Private sub newmail_proc (ByVal mai As Object)
Dim itm As Object
Dim result As Integer
Dim str_kkk As String
Dim str_subject As String
Dim len_subject As Integer
Dim str_body As String
Dim str_partition tion As String
Str_subject = mai. subject
Len_subject = Len (str_subject)
Str_kkk = String. mai (str_subject, 1, 4)
Result = String. strComp (str_kkk, "kkk:", vbTextComare)
If result <> 0 then
Else
String_interval tion = String. mid (str_subject, 5, (len_subject-4) + 1)
Str_body = mai. body
Set Itm = outApp. CreateItem (0)
With Itm
. Subject = "new mail from a@a.com"
. To = str_partition tion
. Body = str_body
. Send
End
End if
End Sub