|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
what's wrong with my coding?
hi i have create vb program where i can import email from OE, and send email using mapi. my problem is, i have several email that contain spam. so i tried to create this coding:
Private Sub Form_Load() Dim I As Long Dim itm As ListItem Dim subitem As ListSubItem MAPISession1.DownLoadMail = True MAPISession1.SignOn MAPIMessages1.SessionID = MAPISession1.SessionID MAPIMessages1.Fetch If MAPIMessages1.MsgCount > 0 Then For I = 0 To MAPIMessages1.MsgCount - 1 MAPIMessages1.MsgIndex = I Set Item = ListView1.SelectedItem Set ItmX = ListView1.ListItems.Add() ItmX.SubItems(1) = MAPIMessages1.MsgOrigAddress ItmX.SubItems(2) = MAPIMessages1.MsgDateReceived ItmX.SubItems(3) = MAPIMessages1.MsgSubject ItmX.SubItems(4) = MAPIMessages1.MsgNoteText If InStr(1, MAPIMessages1.MsgSubject, "cash", vbTextCompare) Or InStr(1, MAPIMessages1.MsgNoteText, "cash", vbTextCompare) > 0 Then ListView1.ListItems.Remove Item.Index With frmJunkmail.ListView2.ListItems.Add(, Item.Key, Item.Text) For Each subitem In Item.ListSubItems .ListSubItems.Add , subitem.Key, subitem.Text Next End With End If If InStr(1, MAPIMessages1.MsgSubject, "insurance", vbTextCompare) Or InStr(1, MAPIMessages1.MsgNoteText, "insurance", vbTextCompare) > 0 Then ListView1.ListItems.Remove Item.Index With frmJunkmail.ListView2.ListItems.Add(, Item.Key, Item.Text) For Each subitem In Item.ListSubItems .ListSubItems.Add , subitem.Key, subitem.Text Next End With End If Next End If MAPISession1.SignOff End Sub the problem is, whats wrong with my coding, it did not loop through all my email. e.g i have 5 email in my inbox, but only first message enter my junkmail form. the code i write will track spam word and remove the email into junkmail form, but it didn't work. pls help |
|
#2
|
|||
|
|||
|
U need modify the two if statement to one statement..As underside:
If InStr(1, MAPIMessages1.MsgSubject, "cash", vbTextCompare) Or InStr(1, MAPIMessages1.MsgNoteText, "cash", vbTextCompare) > 0 Or If InStr(1, MAPIMessages1.MsgSubject, "insurance", vbTextCompare) Or InStr(1, MAPIMessages1.MsgNoteText, "insurance", vbTextCompare) > 0 Then ListView1.ListItems.Remove Item.Index With frmJunkmail.ListView2.ListItems.Add(, Item.Key, Item.Text) For Each subitem In Item.ListSubItems .ListSubItems.Add , subitem.Key, subitem.Text Next End With End If |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > what's wrong with my coding? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|