-
Topic
-
I am trying to write an applet that checks incoming messages and if they have a certain subject field, saves the message text to a file. I used your Virus scanning applet as a base and have all except the last function seems to work. I have 2 problems.
1) Although the applet finds the correct message(s) they are not selected
2) Despite many attempts I can’t seem to get the savemessage command to work (unless I get it to display the dialog box. It either complains about the syntax or does nothing at all.Also I would like the message to show as read after the message text is saved.
Can you help?
Code:
‘
‘ Insert your comments here
‘
‘Global variables
dim Msg
dim HRT
dim FSO
dim iCount
dim FILENAME
dim StringList
dim MailBoxObj
dim NewMsgObj
dim NewMailCount
dim AttachmentNameDEFAULTFOLDER = Utilities.GetDataDirectory
const CAPTION = “Groupwise Solutions”
HLine = “____________________________________________________________________________””””””””””””””””””””””””””””””””””””””””’
‘ Mainline processing
”””””””””””””””””””””””””””””””””””””””’
Sub Main(Client, GWEvent)dim StatusDlg
dim sFilter
HRT = Chr(13) & Chr(10)FILENAME = DEFAULTFOLDER&”CheckOnce.ol”
set StringList = Utilities.StringList
set FSO = CreateObject(“Scripting.FileSystemObject”)‘ Check all messages first and create a file. If file exists then only check the
‘ incoming messages.if FSO.FileExists(FILENAME) then
CheckNewMessages
else
sFilter = (“(MAIL)AND(BOX_TYPE = INCOMING)”)
Set MailBoxObj = GroupWise.Account.MailBox.FindMessages(sFilter)
iCount = MailBoxObj.Count
if (iCount > 1) then
CheckAllInboxMessages
end if
set MailBoxObj = nothing
end if‘ Cleanup all object we created in startup
set FSO = nothing
set StringList = nothingend sub
”””””””””””””””””””””””””””””””””””””””
‘ Check all inbox messages.
‘ This function will run once only. Next time only received mail will check.
”””””””””””””””””””””””””””””””””””””””
sub CheckAllInboxMessagesdim ReadVal
dim MailFoundOn Error Resume Next
Set StatusDlg = Utilities.NewStatusDialog
StatusDlg.ProgressRange = iCount
StatusDlg.Title = CAPTION
StatusDlg.CanCancel = TRUE
StatusDlg.Show‘ set each message object
for x = 1 to iCount
set Msg = MailBoxObj.Item(x)
‘Store read property
ReadVal = Msg.Read
MessageCheck
‘ Check mail for the correct messageStatusDlg.ProgressPosition = x
StatusDlg.MainText = “Mails checked: “&x
StatusDlg.StatusText = “Sender: “&Msg.Sender.DisplayName‘ Quit whole process if user select to exit
if StatusDlg.Cancel then
StatusDlg.Hide
exit sub
end if‘Set the read property
Msg.Read = ReadValset Msg = nothing
next‘ create the file so we don’t check all message next time.
dim TextStream
set TextStream = FSO.CreateTextFile(FILENAME)
TextStream.Write(“Created by – Message Check applet. Date: “&now)
TextStream.Close
set TextStream = nothingStatusDlg.Hide
set Msg = nothing
set StatusDlg = nothingGroupWise.Account.MailBox.Refresh
end sub
”””””””””””””””””””””””””””””””””””””””’
‘ Check only new mails
”””””””””””””””””””””””””””””””””””””””’
function CheckNewMessagesdim sFilter
sFilter = (“(MAIL)AND(BOX_TYPE = INCOMING)AND(NOT READ)”)
On Error Resume Next
Set NewMsgObj = GroupWise.Account.MailBox.FindMessages(sFilter)
NewMailCount = NewMsgObj.Countif NewMailCount> 0 then
CheckMail
end ifset NewMsgObj = nothing
GroupWise.Account.MailBox.Refresh
end function
”””””””””””””””””””””””””””””””””””””””’
‘ Check new mail
”””””””””””””””””””””””””””””””””””””””’
function CheckMaildim ReadVal
for x = 1 to NewMailCount
set Msg = NewMsgObj.Item(x)
‘Store read property
ReadVal = Msg.Read
MessageCheck
Msg.Read = ReadVal
set Msg = nothing
nextend function
”””””””””””””””””””””””””””””””””””””””’
‘ This function will check for the right message and save it to a message file
”””””””””””””””””””””””””””””””””””””””’
function MessageCheck
If Msg.Subject = “BCP status report” then
Set MsgSubj = Msg.Subject
MsgBox(“found it” + ” ” + MsgSubj)
‘GroupWise.ItemSaveMessage (“X00”, “C:Testtestsave.mlm”, 106)
‘GroupWise.ItemSaveMessage(Msg, “C:Testtestsave.mlm”, 106)
GroupWise.ItemSaveMessageDlg
ReadVal = TRUE
end if
end function
- You must be logged in to reply to this topic.