n_athen
asked on
Email checker
I am trying to create a program that will check for new email every 10 minutes,write the new email to an access database and then delete the message.
The code I have does most of this except:
It will not check for new messages unless I log off and log on again.
Also it prompts me to select the profile every time, can this be done a automatically.
___Code____
Option Explicit
Dim ws As Workspace
Dim db As Database
Dim rs As Recordset
Private Sub Command5_Click()
MAPISession1.SignOff
Unload Me
End Sub
Private Sub Form_Load()
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase("c:\vb\TAS KS.MDB")
MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID
End Sub
Private Sub Timer1_Timer()
MAPIMessages1.FetchUnreadO nly = True
If MAPIMessages1.MsgCount > 0 Then
MAPIMessages1.Fetch
Label1.Caption = MAPIMessages1.MsgCount & " messages in que"
Set rs = db.OpenRecordset("tasks")
rs.AddNew
rs!Date = MAPIMessages1.MsgDateRecei ved
rs!From = MAPIMessages1.MsgOrigDispl ayName
rs!email = MAPIMessages1.MsgOrigAddre ss
rs!subject = MAPIMessages1.MsgSubject
rs!message = MAPIMessages1.MsgNoteText
rs.Update
MAPIMessages1.Delete
'rs.Close
'Set rs = Nothing
Else
Label1 = ""
End If
End Sub
The code I have does most of this except:
It will not check for new messages unless I log off and log on again.
Also it prompts me to select the profile every time, can this be done a automatically.
___Code____
Option Explicit
Dim ws As Workspace
Dim db As Database
Dim rs As Recordset
Private Sub Command5_Click()
MAPISession1.SignOff
Unload Me
End Sub
Private Sub Form_Load()
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase("c:\vb\TAS
MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID
End Sub
Private Sub Timer1_Timer()
MAPIMessages1.FetchUnreadO
If MAPIMessages1.MsgCount > 0 Then
MAPIMessages1.Fetch
Label1.Caption = MAPIMessages1.MsgCount & " messages in que"
Set rs = db.OpenRecordset("tasks")
rs.AddNew
rs!Date = MAPIMessages1.MsgDateRecei
rs!From = MAPIMessages1.MsgOrigDispl
rs!email = MAPIMessages1.MsgOrigAddre
rs!subject = MAPIMessages1.MsgSubject
rs!message = MAPIMessages1.MsgNoteText
rs.Update
MAPIMessages1.Delete
'rs.Close
'Set rs = Nothing
Else
Label1 = ""
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks but I those programs are far to advanced for me.
Please ignore the request for system tray
I really just need to know what changes I need to make to my code that will have it check for new mail at a set interval.
thanks
Please ignore the request for system tray
I really just need to know what changes I need to make to my code that will have it check for new mail at a set interval.
thanks
Hi n_athen,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:
Accept AndrewDev's comment(s) as an answer.
n_athen, if you think your question was not answered at all or if you need help, you can simply post a new comment here. Community Support moderators will follow up.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:
Accept AndrewDev's comment(s) as an answer.
n_athen, if you think your question was not answered at all or if you need help, you can simply post a new comment here. Community Support moderators will follow up.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Comment from expert accepted as answer
Computer101
E-E Moderator
Computer101
E-E Moderator
http://www.freevbcode.com/ShowCode.Asp?ID=950