Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old September 24th, 2003, 05:26 AM
schweethoney schweethoney is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 schweethoney User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old September 24th, 2003, 11:08 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > what's wrong with my coding?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway