I searched around but couldn't find an answer. I'm not sure if this is possible, but seems it is.
What I basically want is to get my free/busy status according to Outlook in to a C++ program. For example, I want to check if I have an appointment and then print out "Free" or "Busy". Of course it will awesome if I can also get an description of the appointment.
Is there an easier way of doing this?
Any tutorial or example link owuld be greatly appreciated.
Thank you.
I think this link should help . Let me know.
I am providing the contents of the link below :-
Checking Free/Busy Status
Exchange Server 2003 - Checking Free/Busy Status
Before you send a meeting request, you can check an attendee's calendar to see when the attendee is available. The IAddressee.GetFreeBusy method returns a string of numbers that indicate the attendee's availability for a requested period of time.
Each number in the free/busy string represents an interval of time (every ½ hour in this example). Free time returns 0, Tentative returns 1, Busy returns 2, and Out of Office (OOF) returns 3. If appointments overlap, the highest number is returned. If no free/busy data is available for the interval, the value 4 is returned.
The following figure shows part of an attendee's calendar and the corresponding free/busy string.
The free/busy string for a part of an attendee's calendar
To get an attendee's free/busy status for a specific time, you can create an Addressee object and execute the IAddressee.GetFreeBusy method. You can also get the free/busy status for longer intervals and parse the string to find times the attendee is free.
Note You must first call the IAddressee.CheckName method and resolve the addressee before you can use the IAddressee.GetFreeBusy method.
Note An automated process in Microsoft® Exchange Server 2003 periodically updates the free/busy status of users. Microsoft Outlook® updates the free/busy status of Outlook users. Collaboration Data Objects (CDO) synchronizes the Outlook free/busy cache with free/busy information from CDO clients. The free/busy status is not updated immediately when a meeting is added to a user's calendar. By default, three months' worth of free/busy status is maintained in a system folder in the Exchange store.
This topic contains Microsoft Visual Basic®, Microsoft Visual C++®, Microsoft C#, and Visual Basic .NET code examples.
Visual Basic
The following example returns the free/busy status of the specified user:
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Library
' Note: It is recommended that all input parameters be validated when they are
' first obtained from the user or user interface.
Function GetFreeBusyString(strUserUPN As String, dtStartDate As Date, dtEndDate As Date, Interval As Integer) As String
Dim iAddr As New CDO.Addressee
Dim freebusy As String
Dim Info As New ADSystemInfo
iAddr.EmailAddress = strUserUPN
If Not iAddr.CheckName("LDAP://" & Info.DomainDNSName) Then
' handle error
End If
'Get the free/busy status in Interval minute intervals from dtStartDate to dtEndDate
freebusy = iAddr.GetFreeBusy(dtStartDate, dtEndDate, Interval)
GetFreeBusyString = freebusy
End Function
C++
The following example returns the free/busy status of the specified user:
/*
Assume that the following paths are in your
INCLUDE path.
%CommonProgramFiles%\system\ado
%CommonProgramFiles%\microsoft shared\cdo
*/
#import <msado15.dll> no_namespace
#import <cdoex.dll> no_namespace
#include <iostream.h>
// Note: It is recommended that all input parameters be validated when they are
// first obtained from the user or user interface.
bstr_t getFreeBusyString( const bstr_t& userUPN, const bstr_t& domainDNSName, DATE startDate, DATE endDate, long Interval) {
IAddresseePtr iAddr(__uuidof(Addressee));
iAddr->EmailAddress = userUPN;
if(iAddr->CheckName(bstr_t("LDAP://") + domainDNSName, bstr_t(), bstr_t()) == VARIANT_FALSE) {
cerr << "Error looking up name!" << endl;
_com_issue_error(E_FAIL);
}
//Get the free/busy status in Interval minute intervals from startDate to endDate
return iAddr->GetFreeBusy(startDate, endDate, Interval, bstr_t(), bstr_t(), bstr_t(), bstr_t());
}
C#
The following example returns the free/busy status of the specified user:
// Reference to Microsoft ActiveX Data Objects 2.5 Library
// Reference to Microsoft CDO for Exchange 2000 Library
// Reference to Active DS Type Library
// Note: It is recommended that all input parameters be validated when they are
// first obtained from the user or user interface.
static string GetFreeBusyString(string strUserUPN, DateTime dtStartDate,
DateTime dtEndDate, int Interval)
{
try
{
// Variables.
CDO.Addressee iAddr = new CDO.Addressee();
string freebusy;
ActiveDs.ADSystemInfo Info = new ActiveDs.ADSystemInfo();
iAddr.EmailAddress = strUserUPN;
if (!(iAddr.CheckName("LDAP://" + Info.DomainDNSName, "", "")))
throw new System.Exception("Error occured!");
// Get the free/busy status in Interval minute
// intervals from dtStartDate to dtEndDate.
freebusy = iAddr.GetFreeBusy(dtStartDate, dtEndDate,
Interval, "", "", "", "");
return freebusy;
}
catch (Exception err)
{
Console.WriteLine(err.ToString());
return "";
}
}
Visual Basic .NET
The following example returns the free/busy status of the specified user:
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Library
' Reference to Active DS Type Library
' Note: It is recommended that all input parameters be validated when they are
' first obtained from the user or user interface.
Function GetFreeBusyString(ByVal strUserUPN As String, ByVal dtStartDate As Date, _
ByVal dtEndDate As Date, ByVal Interval As Integer) As String
Try
' Variables.
Dim iAddr As New CDO.Addressee()
Dim freebusy As String
Dim Info As New ActiveDs.ADSystemInfo()
iAddr.EmailAddress = strUserUPN
If Not iAddr.CheckName("LDAP://" & Info.DomainDNSName) Then
Throw New System.Exception("Error occured!")
End If
' Get the free/busy status in Interval minute intervals
' from dtStartDate to dtEndDate.
freebusy = iAddr.GetFreeBusy(dtStartDate, dtEndDate, Interval)
GetFreeBusyString = freebusy
Catch err As Exception
Console.WriteLine(err.ToString())
GetFreeBusyString = ""
End Try
End Function
Related
I added conversion and revenue columns to the script which can be found here.
This is the error I'm getting in the logs (the spreadsheet is updating fine with no issues):
TypeError: newValue.indexOf is not a function
at formatChangeString (Code:366:33)
at emailRow (Code:314:11)
at Code:285:15
at Array.forEach (<anonymous>)
at sendEmail (Code:284:17)
at main (Code:106:7)
formatChangeString(newValue,oldValue) expects newValue to be a string (so that newValue.indexOf('%') can be called.
It seems that one of the metrics you added is returned by the AdsApp.report call as a different type (most likely Number).
If you want a quick workaround, just change the line
const isPercentage = newValue.indexOf('%') >= 0;
to
const isPercentage = String(newValue).indexOf('%') >= 0;
I am able to add call attrs using 'Genesyslab.Platform.Voice.Protocols.TServer.Requests.Userdata.RequestAttachUserData' when the call is online but how to do when the call is dropped?
I found this in WDE
void SelectDispositionCodeSetAttachedData(string dispositionCodeValueName);
//
// Summary:
// Update or add the keys of the specificed KeyValueCollection in the attached data
// of the interaction . The current list of attached data can then be retrieved
// using GetAttachedData. If the interaction media type is 'voice' or 'instant message'
// and the interaction is not released the added/updated values are immediately
// committed to T/SIP Server. If the interaction media type is 'voice' or 'instant
// message' and the interaction is released the added/updated values are sent to
// T/SIP Server as a UserEvent when the interaction is marked done (programmatic?aly
// or by Agent). If it is an eServices interaction (e-mail, chat, etc.) and the
// interaction is still handled by the agent the added/updated values are immediately
// committed to Interaction Server. After e-Services interaction is released, no
// further programmatical update is committed to Interaction Server. For all interaction
// types any attached data programmatical update applied after interaction release
// is not reflected in UI controls such as 'Case information'.
This is my code:
Genesyslab.Platform.Commons.Collections.KeyValueCollection keyValueCollectionUpDate = new Genesyslab.Platform.Commons.Collections.KeyValueCollection();
keyValueCollectionUpDate.Add("Business Result", "Platform: Business Result");
keyValueCollectionUpDate.Add("StrAttribute1", "AttachedData.Business Result"); RequestAttachUserData requestAttachUserData= RequestAttachUserData.Create("7012", GetConnectionID(ExtractedArtributes[1][0].Value.ToString()), keyValueCollectionUpDate); IMessage respondingEvent2=tserverProtocol.Request(requestAttachUserData);
Need to add call attts after the call is dropped
You can't update attached data when the call is dropped.
I do a workaround by using WDE itself to attach data when agent clicks 'mark done' in WDE custom command.
The way to attach data to voice calls after disconnect, is to send a UserEvent. This does require the AfterCallWork state to be enabled in your environment. You have already mentioned understanding how to insert Commands into the Command Chain. This example Execute function of a command can be inserted into the "BundleClose" Command Chain, prior to the "Close" Command.
This sample is in VB, apologies, but I guess you can easily convert to c#.
Public Function Execute(ByVal parameters As IDictionary(Of String, Object), ByVal progress As IProgressUpdater) As Boolean Implements IElementOfCommand.Execute
' To go to the main thread
If Application.Current.Dispatcher IsNot Nothing AndAlso Not Application.Current.Dispatcher.CheckAccess() Then
Dim result As Object = Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, New ExecuteDelegate(AddressOf Execute), parameters, progress)
Return CBool(result)
Else
Dim interactionsBundle As IInteractionsBundle = Nothing
Dim interaction As IInteraction = Nothing
interactionsBundle = parameters("CommandParameter")
interaction = interactionsBundle.MainInteraction
Dim channel As Enterprise.Model.Channel.IClientChannel = interaction.EntrepriseInteractionCurrent.ActiveChannel 'agent.Channel
Dim protocol As IProtocol = channel.Protocol
Dim kvp As Platform.Commons.Collections.KeyValueCollection = New Platform.Commons.Collections.KeyValueCollection()
kvp.Add("keyname", "keyvalue")
Dim userevent As Platform.Voice.Protocols.TServer.CommonProperties = Platform.Voice.Protocols.TServer.CommonProperties.Create()
userevent.UserData = kvp
Dim connID As Platform.Voice.Protocols.ConnectionId = Nothing
Dim interactionVoice as IInteractionVoice = TryCast(interaction, IInteractionVoice)
If interactionVoice IsNot Nothing Then
userevent.UserEvent = Platform.Voice.Protocols.TServer.Events.EventUserEvent.MessageId
connID = New Platform.Voice.Protocols.ConnectionId(interactionVoice.TConnectionId)
Dim strDN As String = Nothing
'ensure the correct DN is passed when attaching reason codes, in case agent is logged into multiple DNs
Dim devices() As Enterprise.Model.Device.IDevice = interactionVoice.Device
Dim device As Enterprise.Core.DN = devices(0)
strDN = device.Name
userevent.ThisDN = strDN
userevent.ConnID = connID
Dim req = Platform.Voice.Protocols.TServer.Requests.Special.RequestSendEvent.Create()
req.UserEvent = userevent
'send request
protocol.Send(req)
End If
End If
End Function
I'm trying to query my Server 2012 Essentials R2 server to determine the most recent Client Backup time for a given Device, so I can display nag screens at signon for forgetful users. (They're on laptops, so I can't depend on the machine being available during the automatic window.)
The closest thing in the way of documentation I've been able to find is this: (https://msdn.microsoft.com/en-us/library/jj713757.aspx)
GET services/builtin/DeviceManagement.svc/devices/index/{index}/count/{count}
But it requires a preceding call to get the token: (https://msdn.microsoft.com/en-us/library/jj713753.aspx)
GET https://www.contoso.com/services/builtin/session.svc/login HTTP/1.1
Accept: application/xml
Host: servername
Authorization: Basic VXNlcjpQYXNzd29yZCE=
AppName: Sample App Name
AppPublisher: publisher
AppVersion: 1.0
Does anyone know what the values for those last three headers should be—or how to discover them—for a standard WSE 2012 R2 installation? The documentation provides no assistance here.
Or if someone knows a better way to accomplish this, please let me know.
OK, I got it working. The code is below.
As it turns out, the value of the AppName header is irrelevant—it can be any string, but it can't be empty.
I already knew it couldn't be empty from a look at the WSE source in Wssg.WebApi.Framework in the GAC, but the code is decoupled to the point that it's next to impossible to find out what process picks up the the RemoteConnectionClientInfo object once it gets dropped into the HTTP session.
The part that was misleading me was—go figure—the documentation itself.
There's a bang (!) after the password on the Authentication page, suggesting that it should trail the actual password prior to encoding. This was why I was getting an authentication error, which in turn I was (mistakenly) attributing to the statement in the documentation: "Add Appname, Apppublisher, and Appversion values in HTTP header fields. These values are also required to log on."
So once I cleared all that up, I sailed right in.
And there are other errors in the documentation. On the Devices page we are told that the Host header should be set to the domain name, and that a Content-Length header should be added.
These are both incorrect. The Host header should be the server's hostname and there should be no Content-Length header (that's a response header, not a request header).
AND...! After all this, I find that the Device info returned doesn't contain the most recent backup time. I'll have to dig further for that. But at least now I can connect.
So Microsoft's incomplete, inaccurate and sloppy documentation has cost me a day's work. Hopefully somebody else can use this and avoid the pain I went through.
Module Main
Public Sub Main()
Dim aCredentials() As Byte
Dim _
oAuthenticateUri,
oDeviceListUri As Uri
Dim _
sCanary,
sCookie,
sDevices As String
aCredentials = Encoding.ASCII.GetBytes($"{USERNAME}:{PASSWORD}")
Using oClient As New HttpClient
oAuthenticateUri = New Uri($"https://{HOST}/services/builtin/session.svc/login")
oDeviceListUri = New Uri($"https://{HOST}/services/builtin/devicemanagement.svc/devices/index/0/count/99")
oClient.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/xml"))
oClient.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("Basic", Convert.ToBase64String(aCredentials))
oClient.DefaultRequestHeaders.Host = HOST
oClient.DefaultRequestHeaders.Add("AppPublisher", String.Empty)
oClient.DefaultRequestHeaders.Add("AppVersion", String.Empty)
oClient.DefaultRequestHeaders.Add("AppName", "None")
Using oAuthenticateResponse As HttpResponseMessage = oClient.GetAsync(oAuthenticateUri).Result
If oAuthenticateResponse.IsSuccessStatusCode Then
sCanary = oAuthenticateResponse.Headers.Single(Function(Pair) Pair.Key = CANARY_HEADER).Value(0)
sCookie = Split(oAuthenticateResponse.Headers.Single(Function(Pair) Pair.Key = COOKIE_HEADER).Value(0), ";")(0)
oClient.DefaultRequestHeaders.Clear()
oClient.DefaultRequestHeaders.Host = HOST
oClient.DefaultRequestHeaders.Add(CANARY_HEADER, sCanary)
oClient.DefaultRequestHeaders.Add(COOKIE_HEADER, sCookie)
Using oDeviceListResponse As HttpResponseMessage = oClient.GetAsync(oDeviceListUri).Result
If oDeviceListResponse.IsSuccessStatusCode Then
sDevices = oDeviceListResponse.Content.ReadAsStringAsync.Result
Else
Console.WriteLine("{0} ({1})", oDeviceListResponse.StatusCode, oDeviceListResponse.ReasonPhrase)
End If
End Using
Else
Console.WriteLine("{0} ({1})", oAuthenticateResponse.StatusCode, oAuthenticateResponse.ReasonPhrase)
End If
End Using
End Using
End Sub
Private Const CANARY_HEADER As String = "Canary"
Private Const COOKIE_HEADER As String = "Set-Cookie"
Private Const USERNAME As String = "domain.admin"
Private Const PASSWORD As String = "admin.password"
Private Const HOST As String = "server"
End Module
As far as I understood, the ReportEvent function requires Message Text Files associated through the registry to receive properly formatted messages. Is there any common Event Ids or any simple way to report an event with no Message Text Files associated?
Or may be, is there special common Event Source which I can use in my application? Something like RegisterEventSource(NULL, "Application")?
You don't have to register your messages in HKLM. (Which is a good thing, because you can't register messages if you're not an administrator).
But that doesn't stop you from writing events to the Windows Application event log. The only downside is that starting with Windows Vista you'll just get some ugly text along with it.
HRESULT LogToEventLog(String Source, String EventText, int EventType, DWORD EventID)
{
/*
EventType is one of:
EVENTLOG_ERROR_TYPE = $0001;
EVENTLOG_WARNING_TYPE = $0002;
EVENTLOG_INFORMATION_TYPE = $0004;
EVENTLOG_AUDIT_SUCCESS = $0008;
EVENTLOG_AUDIT_FAILURE = $0010;
Source is your name for your app or feature, e.g.:
"My Cool App"
"Outlook"
"ESENT"
"Chrome"
*/
HANDLE h = RegisterEventSource(null, Source); //null --> local computer
if (h == 0)
return HResultFromWin32(GetLastError);
try
{
PChar[1] ss;
ss[0] = PChar(EventText);
if (!ReportEvent(
h, // event log handle
EventType, // event type
0, // category zero
EventID, // event identifier
null, // no user security identifier
1, // one substitution string
0, // no data
#ss, // pointer to string array
null // pointer to data
))
{
return HResultFromWin32(GetLastError);
}
}
finally
{
DeregisterEventSource(h);
}
return S_OK;
}
And so now you can log events to the Application event log:
LogToEventLog("Stackoverflow", "Question 5399066 was answered by Ian Boyd",
EVENTLOG_INFORMATION_TYPE, 0x45);
Steal someone else's registration
Unfortunately, starting with Windows Vista, Windows will give ugly complaints that you didn't register the event beforehand:
The description for Event ID 69 from source Stackoverflow cannot be
found. Either the component that raises this event is not installed on
your local computer or the installation is corrupted. You can install
or repair the component on the local computer.
If the event originated on another computer, the display information
had to be saved with the event.
The following information was included with the event:
Question 5399066 was answered by Ian Boyd
But you don't have to live with it. Just because you didn't register an message source file in HKLM, doesn't mean nobody else did.
Notice, for example, a message from the Outlook source in the Event log:
Source: Outlook
EventID: 0x40000020
Event Data: D:\win32app\Exchange\Outlook2003.pst
Message: The store D:\win32app\Exchange\Outlook2003.pst has detected a catalog checkpoint.
You can check registration information for Outlook in:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Outlook
And see:
MessageEventFile: REG_SZ = "D:\Programs\MICROS~4\Office14\1033\MAPIR.DLL"
If you peek into the resources of MAPIR.dll binary, you'll see its Message Table:
1 MESSAGETABLE
{
0x12, "Connection stats for server (%1). Rpcs Attempted (%2), Rpcs Succeeded (%3), Rpcs Failed (%4), Rpcs Canceled (%5), Rpc UI shown (%6), Avg request time (%7) ms, Min request time (%8) ms, Max request time (%9) ms.\r\n"
0x14, "Cancelable RPC started.\r\n"
0x15, "Cancelable RPC shutdown.\r\n"
0x40000010, "Cancelable RPC dialog shown for server (%1), total wait time was (%2) ms, result was (%3).\r\n"
0x40000011, "User canceled request against server (%1) after waiting (%2) ms.\r\n"
0x40000013, "Rpc call (%1) on transport (%2) to server (%3) failed with error code (%4) after waiting (%5) ms; eeInfo (%6).\r\n"
0x40000016, "There was a problem reading one or more of your reminders. Some reminders may not appear.\r\n"
0x40000017, "Unable to update public free/busy data.\r\n"
0x4000001A, "%1\r\n"
0x4000001B, "%1\r\n"
0x4000001D, "The store %1 is being re-pushed to the indexer for the following reason: %2.\r\n"
0x4000001E, "Starting reconciliation for the store %1 for the following reason: %2.\r\n"
0x4000001F, "The store %1 has detected a catalog rebuild.\r\n"
0x40000020, "The store %1 has detected a catalog checkpoint.\r\n"
...
}
You can see that eventid 0x40000020 is assocated with a formatting string:
"The store %1 has detected a catalog checkpoint.\r\n"
You can hijack Outlook's registration:
LogToEventLog("Outlook", "Your mom", EVENTLOG_INFORMATION_TYPE, $40000020);
and you'll get your event added to the event log without all the ugly warnings:
No, you just have to follow the rules and define your message text files, build them into resources, link them to your app etc.
The example provided at MSDN leads you through everything you need to do.
Try this out, it's worked for me before..
http://www.codeproject.com/KB/system/xeventlog.aspx
The target is someone's Exchange Calendar (2007). I want to add a simple "Appointment Occurance" to someone's calendar. This code works (I am using the Microsoft.Exchange.WebServices.dll):
service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new NetworkCredential("supervisor", "password", "DOMAIN.COM");
service.AutodiscoverUrl("<employee#domain.com>", ValidateRedirectionUrlCallback);
appt = new Appointment(service);
appt.Subject = "<subject>";
appt.Body = "<Body Text>";
appt.Start = _DateFrom;
appt.End = _DateTo;
appt.Sensitivity = Sensitivity.Private;
appt.Save(WellKnownFolderName.Calendar);
However, there are problems with this code:
The appointment target is the employee. When adding the appointment, the appointment shows up for the employee (yay!) but also for the supervisor (boo!). Am I supposed to use the employee's credentials? If so, what if I do not have access to that - only the supervisors, am I out of the game already?
The appointment shows up in Outlook as a "Meeting Appointment" and not and "Appointment Occurrence". So, the box to input meeting attendees is showing (with no one in it of course), and is irrelevant in my scenario.
appt.Body does not respond at all to Environment.NewLine or "\r\n" - I haven't tried HTML yet.
Instead of WellKnownFolderName.Calendar
You should use new FolderId(WellKnownFolderName.Calendar,"employee#domain.com")
So the last line becomes
appt.Save(new FolderId(WellKnownFolderName.Calendar,"employee#domain.com"));
Also having problems with the newline, this is only since version 1.1 so it probebly is a bug