Sessions

  • Thread starter Thread starter Amit Naik
  • Start date Start date
A

Amit Naik

Hi there,

I have a problem which should be easy to solve but have
pulled my hair out over, can you please help..

I have created a custom form and published it to a public
folder. I now want to run an exchange event script on the
server triggered when a new form is created. I have
written the code as follows:

' DESCRIPTION: This event is fired when a new message is
added to the folder
Public Sub Folder_OnMessageCreated

Dim MySession
Set MySession = EventDetails.Session
MySession.Logon "uk\wkflowadmin", "fl0wh0me", False, True,
0, False

Dim MyFolder
Set MyFolder = MySession.GetFolder(EventDetails.FolderID)

Dim a
For a = 1 To myFolder.Messages.Count
Dim myitem
Set myitem = myFolder.Messages.Item(a)
Dim Count
For Count = 2 To 7
Dim statusbox
statusbox = "Status" & Count
If myitem.Fields(statusbox) = "Started"
Then
Dim deadline
deadline = "Deadline" & Count
If Date > myitem.Fields(deadline)
Then
Dim myemail
Set myemail = CreateObject
("CDO.Message")
Dim mymessage
mymessage = "A task is
overdue for this workflow so please follow it up" & vbCr
mymessage = mymessage
& "<outlook://public folders/all public
folders/FinalWorkflow/~" & myitem.Subject & ">"
myemail.TextBody =
mymessage
myemail.Subject =
myitem.Subject
myemail.From
= "Administrator"
myemail.To = myitem.Fields
("Task1Assign")
myemail.Send ' this should
send the mail to the task owner from the administrator
End If
End If
Next
Next

End Sub

However, I keep getting the following error message :

10/09/03 17:54:53 Run time error at line 22. Source:
Collaboration Data Objects Error: 4f9. Description:
[Collaboration Data Objects - [MAPI_E_LOGON_FAILED
(80040111)]]

What am I doing wrong? I hope you can help,

Thanks in advance

Amit
 
The session object that EventDetails passes is already logged on. Don't do another logon unless you want to create another session to access a different mailbox.

What's line 22?

FYI, the microsoft.public.exchange.applications group would be a more appropriate forum for Exchange scripting questions.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Back
Top