Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Problem with code

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,34
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem with code
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Problem with code - 5/23/2001 7:02:16 AM   
  eak_guy

 

Posts: 15
Score: 0
Joined: 5/23/2001
From: USA
Status: offline
I have a problem with this code. It suppose to recieve a email and it checks the subject and if the subject is either "remove" or "registation" it add or removes the sender address to/from a database. For some reason it come up with an error here:

Dim objMessage as MAPI.Message

It says that there's an "unexpected end of statement"


Here's the whole code:

Option Explicit

' Database Variables
Dim objConn, ObjRS, strQuery
Dim strConnection
Dim strAddress, StrSubject

' Mail Variables
'Dim cdoSession, inbox, messages, message, msgID, i

Dim objMessage as MAPI.Message
Dim objMessages as MAPI.Messages
Dim objFolder as MAPI.Folder
Dim objSession as MAPI.Session

'Const adUseServer = 2
'Const adOpenKeyset = 1
'Const adCmdTable = 2
'Const adLockOptimistic = 3

Set objSession = CreateObject ("MAPI.Session");
objSession.logon
Set objFolder = objSession.Inbox
Set objMessages = objFolder.Messages
Set objMessageFilter= objMessages.Filter
objMessageFilter.Or= True
objMessageFilter.Subject="Remove"
objMessageFilter.Subject="Registration"
Set objMessage=objMessages.GetFrist

If objMessage Is Nothing Then
MsgBox "Folder is Empty"
else
'loop through other messages
Do While Not objMessage Is Nothing

strAddress= objMessage.Sender
strSubject = objMessage.Subject

'Set objConn = Server.CreateObject("ADODB.Connection")
'strConnection= "DSN=POCKETMOSAIC"
' objConn.Open strConnection
' strQuery= "SELECT PagerAddress FROM Users "
' strQuery= strQuery & "ORDER BY PagerAddress"

'if the pager address needs to be removed from the db
if strSubject = "Remove" then
MsgBox "remove"
' While not(objRS.EOF)
'if objRS("PagerNumber") = strAddress Then
' objRS.Delete
' MsgBox strAddress
'end if
' wend

'if the pager address need to be added to the db
Else StrSubject = "Registration" then
MsgBox "Add"
' objRS.AddNew
' objRS("PagerNumber")=strAddress

' objRS.Update
MsgBox strAddress

End if
Set objMessage= objMessage.GetNext
Loop
End if
' objRS.close
' objConn.close

Set objMessage = nothing
Set objMessages = nothing
Set objFolder= nothing
Set objSession = nothing
Set objRS = nothing
set objConn= nothing
MsgBox "Done!"

'cdoSession.Logoff
 
 
Post #: 1
 
 Re: Problem with code - 5/23/2001 7:05:03 AM   
  adminkoe

 

Posts: 117
Score: 0
Joined: 12/23/2000
From:
Status: offline
In order to declare objects in vbscript, it's a two step process -- what you have posted works in regular vb

Dim objMessage as MAPI.Message

should be

dim objMessage
set objMessage = server.createobject("MAPI.Message")

(in reply to eak_guy)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem with code Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts