Lader til det ikke er så nemt som jeg regnede med!
Jeg har fået en kopi af en exchange database, da den IT ansvarlige på mit arbejde ikke tør lade mig få direkte adgang til exchange serveren. Dvs. jeg har fået en "pub1.edb" fil som jeg gerne vil have lov til at rode med.
Er det ikke muligt direkte lave en connection string direkte til denne fil type?
Ja, det er muligt, men selve nøgleordene i forbindelse med den Sql du skal anvende er lidt speciel og det nemmeste er derfor hvis du finder noget kode og tilretter det. Nedenstående adresse indeholder forskellige slags eksempler, hvor der forbindelse til exchange.
http://www.cdolive.com/default.htmTil inspiration. Nedenstående kode snippet flag'er automatisk alle indkomne beskeder med Fellow-Up.
<SCRIPT RunAt=Server Language=VBScript>
'THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
'WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
'INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
'OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
'PURPOSE
'------------------------------------------------------------------------------
'
' NAME: AutoFlag
'
' FILE DESCRIPTION: Automatically flag all incomming messages for follow up.
'
' Copyright (c) CdoLive 1999. All rights reserved.
' Http://www.cdolive.com
' Mailto:samples@cdolive.com
'
' Portions:
' Copyright (c) Microsoft Corporation 1993-1997. All rights reserved.
'
'------------------------------------------------------------------------------
Option Explicit
'------------------------------------------------------------------------------
' Global Variables
'------------------------------------------------------------------------------
Dim g_bstrDebug ' Debug String
'------------------------------------------------------------------------------
' CONSTANTS
'------------------------------------------------------------------------------
' Outlook property set ID
Const CdoPropSetID4 = "0820060000000000C000000000000046"
' MAPI property tags used in this script
Const CdoPR_REPLY_REQUESTED = &H0C17000B
Const CdoPR_RESPONSE_REQUESTED = &H0063000B
Const CdoPR_REPLY_TIME = &H00300040
Const CdoPR_FLAG_STATUS = &H10900003
Const CdoPR_FLAG_TEXT = "0x8530"
Const CdoPR_FLAG_DUE_BY = "0x8502"
Const CdoPR_FLAG_DUE_BY_NEXT = "0x8560"
Const CdoPR_FLAG_COMPLETE = &H10910040
Const FLAG_NONE = 0
Const FLAG_WHITE = 1
Const FLAG_RED = 2
' Used in both, messages (IPM.Note) and contacts (IPM.Contact)
Const FLAG_CALL = "Call"
Const FLAG_FOR_FOLLOW_UP = "Follow up"
' Only used in messages (IPM.Note)
Const FLAG_DO_NOT_FORWARD = "Do not Forward"
Const FLAG_FOR_YOUR_INFORMATION = "For Your Information"
Const FLAG_FORWARD = "Forward"
Const FLAG_NO_RESPONSE_NECESSARY = "No Response Necessary"
Const FLAG_READ = "Read"
Const FLAG_REPLY = "Reply"
Const FLAG_REPLY_TO_ALL = "Reply to All"
Const FLAG_REVIEW = "Review"
' Only used in Outlook contacts (IPM.Contact)
Const FLAG_ARRANGE_MEETING = "Arrange Meeting"
Const FLAG_SEND_E_MAIL = "Send E-mail"
Const FLAG_SEND_LETTER = "Send Letter"
' Desired action that should be used
Dim g_Flag_Action
Dim g_Flag_Due_By
' Set action to call and due by to tomorrow
' Change this values if you want to have the flag set to another
' action and due date
g_Flag_Action = FLAG_CALL
g_Flag_Due_By = Now + 1
'------------------------------------------------------------------------------
' EVENT HANDLERS
'------------------------------------------------------------------------------
' DESCRIPTION: This event is fired when a new message is added to the folder
Public Sub Folder_OnMessageCreated
' Declare variables
Dim objSession ' Session
Dim objCurrentMsg ' Current message
Dim objFields ' Message fields
' Initialize variables
Set objSession = Nothing
Set objCurrentMsg = Nothing
Set objFields = Nothing
' Clear error buffer
Err.Clear
' Get session informationen
On Error Resume Next
Set objSession = EventDetails.Session
' No errors detected ?
If Err.Number = 0 Then
' Write some logging
Call DebugAppend(objSession.CurrentUser & " AutoFlag - Proccessing startet", False)
' Get current message
Err.Clear
On Error Resume Next
Set objCurrentMsg = objSession.GetMessage(EventDetails.MessageID,Null)
' Error detected ?
If Err.Number <> 0 Then
' Error reading current message
Call DebugAppend("Error - Could not read current message", True)
Else
' Remember subject of current message
Call DebugAppend("New message with subject: <" & objCurrentMsg.Subject & "> arrived", False)
' Get fields collection of current message
On Error Resume Next
Set objFields = objCurrentMsg.Fields
' Check if fields collection found
If Not objFields Is Nothing Then
' Add red flag to current message
Err.Clear
On Error Resume Next
objFields.Add CdoPR_FLAG_STATUS, FLAG_RED
' No errors detected ?
If Err.Number = 0 Then
' Message flagged red, write logging
Call DebugAppend("Message flagged red", False)
' Set flag status fields
On Error Resume Next
objFields.Add CdoPR_REPLY_REQUESTED, True
On Error Resume Next
objFields.Add CdoPR_RESPONSE_REQUESTED, True
On Error Resume Next
objFields.Add CdoPR_FLAG_TEXT, 8, g_Flag_Action, CdoPropSetID4
' Write some logging
Call DebugAppend("Message flagged to: " & g_Flag_Action, False)
' Check if Due by date is not empty
If IsDate(g_Flag_Due_By) = True Then
' Set due date
On Error Resume Next
objFields.Add CdoPR_FLAG_DUE_BY, 7, g_Flag_Due_By, CdoPropSetID4
On Error Resume Next
objFields.Add CdoPR_FLAG_DUE_BY_NEXT, 7, g_Flag_Due_By, CdoPropSetID4
On Error Resume Next
objFields.Add CdoPR_REPLY_TIME, g_Flag_Due_By
' Write some logging
Call DebugAppend("Message due date set to: " & g_Flag_Due_By, False)
End If
' Update current message
On Error Resume Next
objCurrentMsg.Update True, True
' Mark current message as read
objCurrentMsg.Unread = False
End If
End If
End If
Else
' Write some logging
Call DebugAppend("Undefinied Error detected", True)
End If
' Write some logging, without the folder name
Call DebugAppend("AutoFlag - Processing finished", False)
' Clear objects
Set objSession = Nothing
Set objCurrentMsg = Nothing
Set objFields = Nothing
' Write results to the Scripting Agent log
Script.Response = g_bstrDebug
End Sub
' DESCRIPTION: This event is fired when the timer on the folder expires
Public Sub Folder_OnTimer
'Not used
End Sub
' DESCRIPTION: This event is fired when a message in the folder is changed
Public Sub Message_OnChange
'Not used
End Sub
' DESCRIPTION: This event is fired when a message is deleted from the folder
Public Sub Folder_OnMessageDeleted
'Not used
End Sub
'-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
' PRIVATE FUNCTIONS/SUBS
'-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
'------------------------------------------------------------------------------
' Name: DebugAppend
' Area: Debug
' Desc: Simple Debugging Function
' Parm: String Text, Bool ErrorFlag
'------------------------------------------------------------------------------
Private Sub DebugAppend(bstrParm,boolErrChkFlag)
If boolErrChkFlag = True Then
If Err.Number <> 0 Then
g_bstrDebug = g_bstrDebug & bstrParm & " - " & cstr(Err.Number) & " " & Err.Description & vbCrLf
Err.Clear
End If
Else
g_bstrDebug = g_bstrDebug & bstrParm & vbCrLf
End If
End Sub
</SCRIPT>
Jeg synes du skal spørge den IT ansvarlige om du ikke kan få stillet en udvikl. testserver (og ikke kun en .edb fil, da ikke alt ligger i den fil) til rådighed, som du kan afprøve dit program på og teste det inden du ruller det ud på produktionsserveren.
Indlæg senest redigeret d. 14.11.2007 22:38 af Bruger #10448