retrieve members of a nested distribution group in outlook using c# - outlook

I am developing an Outlook 2013 add-in in which I have to expand the distribution groups(which may or may not be nested) into its constituent member's names as soon as the group is selected from the Outlook Address Book.How can this be achieved?
I am totally novice at it,henceforth no source code has been mentioned.Any help would be much appreciated.

I'd suggest starting from the Getting Started with VBA in Outlook 2010 article in MSDN.
private void GetDistributionListMembers()
{
Outlook.SelectNamesDialog snd =
Application.Session.GetSelectNamesDialog();
Outlook.AddressLists addrLists =
Application.Session.AddressLists;
foreach (Outlook.AddressList addrList in addrLists)
{
if (addrList.Name == "All Groups")
{
snd.InitialAddressList = addrList;
break;
}
}
snd.NumberOfRecipientSelectors =
Outlook.OlRecipientSelectors.olShowTo;
snd.ToLabel = "D/L";
snd.ShowOnlyInitialAddressList = true;
snd.AllowMultipleSelection = false;
snd.Display();
if (snd.Recipients.Count > 0)
{
Outlook.AddressEntry addrEntry =
snd.Recipients[1].AddressEntry;
if (addrEntry.AddressEntryUserType ==
Outlook.OlAddressEntryUserType.
olExchangeDistributionListAddressEntry)
{
Outlook.ExchangeDistributionList exchDL =
addrEntry.GetExchangeDistributionList();
Outlook.AddressEntries addrEntries =
exchDL.GetExchangeDistributionListMembers();
if (addrEntries != null)
foreach (Outlook.AddressEntry exchDLMember in addrEntries)
{
Debug.WriteLine(exchDLMember.Name);
}
}
}
}
See How to: Get Members of an Exchange Distribution List for more information.
You may find the How Do I... (Outlook 2013 PIA Reference) section in MSDN helpful.

Related

Modified the description for single instance/exception in recurrence appointment does not reflecting in Outlook?

Hi,
We have our custom "Store Provider" written for Outlook.
Problem occur when we have modified the single instance in recurrence appointment in Outlook it does not reflecting in calendar view.
This is working fine with Outlook 2010 and 2013 but does not works Outlook 2016 onwards.
Does not knowing which property need to be set for the Outlook 2016?
For Outlook 2010 we are setting below properties which is working as expected:
Observed that commenting the PR_HTML property for meeting works with the Outlook 2016 as it shows description from PR_BODY_W property. Does this means that i am setting wrongly PR_HTML property.
props[index].dwAlignPad = 0;
props[index].ulPropTag = PR_BODY_W;
props[index++].Value.lpszW = pwszTemp;
props[index].dwAlignPad = 0;
props[index].ulPropTag = PR_INTERNET_CPID;
props[index++].Value.l = lCodePage;
***props[index].dwAlignPad = 0;
props[index].ulPropTag = PR_HTML;
props[index].Value.bin.lpb = (LPBYTE)spAnsiiHTML.get();
props[index++].Value.bin.cb = (ULONG)strlen(spAnsiiHTML.get());
Modifying the single instance in recurring appointment creating an exception. But we are not setting any code in exception stream does we need to set there? Below is the code how we are creating the exception stream:
hResult = lpMessage->OpenProperty(m_ApptOrTask.GetRecurringStreamTag(), &IID_IStream, STGM_READWRITE, MAPI_MODIFY, (LPUNKNOWN *)pRecurrenceStream.getptr());
if (FAILED(hResult) && (MAPI_E_NOT_FOUND == hResult))
{
// we need to try to create this stream
hResult = lpMessage->OpenProperty(m_ApptOrTask.GetRecurringStreamTag(), &IID_IStream, STGM_READWRITE, MAPI_CREATE | MAPI_MODIFY, (LPUNKNOWN *)pRecurrenceStream.getptr());
if (FAILED(hResult))
{
LOG_ERROR(_T("Cannot open reccurrence pattern stream"));
return hResult;
}
}
// m_wRecurFrequency
hResult = pStream->Write(&m_wRecurFrequency, sizeof (WORD), &cbWritten);
if (FAILED(hResult) || (cbWritten != sizeof (WORD)))
{
LOG_ERROR(_T("Failed to write recurrence stream: m_wRecurFrequency"));
return MAPI_E_CALL_FAILED;
}
// m_wPatternType
hResult = pStream->Write(&m_wPatternType, sizeof (WORD), &cbWritten);
if (FAILED(hResult) || (cbWritten != sizeof (WORD)))
{
LOG_ERROR(_T("Failed to write recurrence stream: m_wPatternType"));
return hResult;
}
Any pointers or solution will be appreciated.
Thanks in Advance!

Programmatically access TFS annotations to determine owner

I'm working on a project team and our application is in TFS. I'm attempting to determine how many lines of code each team member is responsible. In TFS, I'm aware of the Annotate feature in the Visual Studio interface which allows you to see who last modified each line of code so I know TFS has this information.
I've written a small console app which accesses my TFS project and all its files, but I now need to programmatically access annotations so I can see who the owner of each line is. Here is my existing code:
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
public class Program
{
static void Main(string[] args)
{
var credentials = new NetworkCredential(username, password, domain);
var server = new TfsTeamProjectCollection(new Uri(serverUrl), credentials);
var version = server.GetService(typeof(VersionControlServer)) as VersionControlServer;
var items = version.GetItems(projectPath, RecursionType.Full);
var fileItems = items.Items.Where(x => x.ItemType == ItemType.File);
foreach (var fileItem in fileItems)
{
var serverItem = fileItem.ServerItem;
//TODO: retrieve and parse annotations
}
}
}
I can't seem to figure out how to retrieve annotations once I have the TFS item. This link explains how to do it by calling TFPT, but after implementing it (tfpt annotate /noprompt <filename>), you are only give the last changeset and code per line, not the owner.
I also found a Microsoft.TeamFoundation.VersionControl.Server namespace that has an Annotation class. I installed TFS on my machine to have access to that DLL, but it doesn't seem like it is of any help to this problem.
How can you programmatically access TFS annotations to determine the owner of a line of code for a file?
You may have to query the branch when a Item's change type is Branch.
For a simple example, there is a scenario
$/Project
/Main`
/a.txt
/Develop
/a.txt (branched from main)
When you query the history of $/project/Develop/a.txt, you can also get the history of $/project/Main/a.txt using following code
void GetAllHistory(string serverItem)
{
var changesets=vcs.QueryHistory(serverItem,
Microsoft.TeamFoundation.VersionControl.Client.VersionSpec.Latest,
0,
Microsoft.TeamFoundation.VersionControl.Client.RecursionType.None,
null,
new Microsoft.TeamFoundation.VersionControl.Client.ChangesetVersionSpec(1),
Microsoft.TeamFoundation.VersionControl.Client.VersionSpec.Latest,
int.MaxValue,
true,
false);
foreach (var obj in changesets)
{
Microsoft.TeamFoundation.VersionControl.Client.Changeset cs = obj as Microsoft.TeamFoundation.VersionControl.Client.Changeset;
if (cs == null)
{
return;
}
foreach (var change in cs.Changes)
{
if (change.Item.ServerItem != serverItem)
{
return;
}
Console.WriteLine(string.Format("ChangeSetID:{0}\tFile:{1}\tChangeType:{2}", cs.ChangesetId,change.Item.ServerItem, change.ChangeType));
if ((change.ChangeType & Microsoft.TeamFoundation.VersionControl.Client.ChangeType.Branch) == Microsoft.TeamFoundation.VersionControl.Client.ChangeType.Branch)
{
var items=vcs.GetBranchHistory(new Microsoft.TeamFoundation.VersionControl.Client.ItemSpec[]{new Microsoft.TeamFoundation.VersionControl.Client.ItemSpec(serverItem, Microsoft.TeamFoundation.VersionControl.Client.RecursionType.None)},
Microsoft.TeamFoundation.VersionControl.Client.VersionSpec.Latest);
GetAllHistory(items[0][0].Relative.BranchToItem.ServerItem);
}
}
}
}

Is there a way to check if a user has really rated your app?

I'm writing a WP7 application and I have code to ask the user for a marketplace review every five runs with an exponential back off so it is less annoying. If the user clicks 'ok' on my "would you like to review" message box, I launch the review task and I store that the user has reviewed the application so I don't ask again.
var marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();
IsolatedStorageSettings.ApplicationSettings["HasReviewed"] = true;
However, while it's likely they did rate the app, I'm actually not a 100% sure they did. Is there a way to check if the current user really has written a review? Does the MarketplaceReviewTask() have a returnvalue? I haven't been able to find anything that indicates I can listen for it.
No, MarketplaceReviewTask does not have any events which return a value. A case with most of the Launcher tasks. Chooser tasks have events to collect the information. Like #willmel said in the comment, it does look like an invasion of privacy.
You can create a check which will check locally if user has rated the application earlier or not. Take a look at following code:
public void reviewfunction()
{
//For Windows phone 8 app
var settings = IsolatedStorageSettings.ApplicationSettings;
//For windows phone 8.1 app or universal app use the following line of code
//var settings = Windows.Storage.ApplicationData.Current.LocalSettings;
//set the app name
string Appname = "My app";
if (!settings.Contains("review"))
{
settings.Add("review", 1);
settings.Add("rcheck", 0);
}
else
{
int no = Convert.ToInt32(settings["review"]);
int check = Convert.ToInt32(settings["rcheck"]);
no++;
if ((no == 4 || no == 7 || no % 10 == 0) && check == 0)
{
settings["review"] = no;
MessageBoxResult mm = MessageBox.Show("Thank you for using this application.\nWould you like to give some time to rate and review this application to help us improve", Appname, MessageBoxButton.OKCancel);
if (mm == MessageBoxResult.OK)
{
settings["rcheck"] = 1;
MarketplaceReviewTask rr = new MarketplaceReviewTask();
rr.Show();
}
}
else
{
settings["review"] = no;
}
}
}
Hope this helps you. Source code can be downloaded from here.

Getting Web Site Name from Web Project Setup

I'm creating a setup project for WCF net-tcp service. One thing I came across is that I need to change "Web Site->Manage Application->Advanced settings->Enabled Protocols". It can be also done using command line:
%windir%\system32\inetsrv\appcmd.exe set app "[Web Site Name]/[Applicaiton Name]" /enabledProtocols:http,net.tcp
The problem is in custom action I can get [TARGETSITE] but it's value is "/LM/W3SVC/2" (I have [TARGETVDIR] too). The question is how can I get Web Site Name or how can I use [TARGETSITE] to set application enabled protocols?
The solution I ended with involves converting metabasePath to site name and then using appcmd:
private static string GetSiteName(string metabasePath)
{
var siteIdString = metabasePath.Substring(metabasePath.LastIndexOf("/") + 1);
long siteId;
long.TryParse(siteIdString, out siteId);
if (siteId != 0)
{
var iisManager = new ServerManager();
var config = iisManager.GetApplicationHostConfiguration();
var sites = config.GetSection("system.applicationHost/sites").GetCollection();
ConfigurationElement selectedSite = null;
foreach (var site in sites)
{
if ((long)site.GetAttribute("id").Value == siteId)
selectedSite = site;
}
if (selectedSite != null)
{
return selectedSite.GetAttribute("name").Value as string;
}
}
return null;
}
To use this you will have to reference:
C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll
C:\Windows\System32\inetsrv\Microsoft.Web.Management.dll

Windows Workflow Foundation 4.0 and Tracking

I'm working with the Beta 2 version of Visual Studio 2010 to get some advanced learning using WF4. I've been working with the SqlTracking Sample in the WF_WCF_Samples SDK, and have gotten a pretty good understanding of how to emit and store tracking data in a SQL Database, but haven't seen anything on how to query the data when needed. Does anyone know if there are any .Net classes that are to be used for querying the tracking data, and if so are there any known samples, tutorials, or articles that describe how to query the tracking data?
According to Matt Winkler, from the Microsoft WF4 Team, there isn't any built in API for querying the tracking data, the developer must write his/her own.
These can help:
WorkflowInstanceQuery Class
Workflow Tracking and Tracing
Tracking Participants in .NET 4 Beta 1
Old question, I know, but there is actually a more or less official API in AppFabric: Windows Server AppFabric Class Library
You'll have to find the actual DLL's in %SystemRoot%\AppFabric (after installing AppFabric, of course). Pretty weird place to put it.
The key classes to look are at are SqlInstanceQueryProvider, InstanceQueryExecuteArgs. The query API is asynchronous and can be used something like this (C#):
public InstanceInfo GetWorkflowInstanceInformation(Guid workflowInstanceId, string connectionString)
{
var instanceQueryProvider = new SqlInstanceQueryProvider();
// Connection string to the instance store needs to be set like this:
var parameters = new NameValueCollection()
{
{"connectionString", connectionString}
};
instanceQueryProvider.Initialize("Provider", parameters);
var queryArgs = new InstanceQueryExecuteArgs()
{
InstanceId = new List<Guid>() { workflowInstanceId }
};
// Total ruin the asynchronous advantages and use a Mutex to lock on.
var waitEvent = new ManualResetEvent(false);
IEnumerable<InstanceInfo> retrievedInstanceInfos = null;
var query = instanceQueryProvider.CreateInstanceQuery();
query.BeginExecuteQuery(
queryArgs,
TimeSpan.FromSeconds(10),
ar =>
{
lock (synchronizer)
{
retrievedInstanceInfos = query.EndExecuteQuery(ar).ToList();
}
waitEvent.Set();
},
null);
var waitResult = waitEvent.WaitOne(5000);
if (waitResult)
{
List<InstanceInfo> instances = null;
lock (synchronizer)
{
if (retrievedInstanceInfos != null)
{
instances = retrievedInstanceInfos.ToList();
}
}
if (instances != null)
{
if (instances.Count() == 1)
{
return instances.Single();
}
if (!instances.Any())
{
Log.Warning("Request for non-existing WorkflowInstanceInfo: {0}.", workflowInstanceId);
return null;
}
Log.Error("More than one(!) WorkflowInstanceInfo for id: {0}.", workflowInstanceId);
}
}
Log.Error("Time out retrieving information for id: {0}.", workflowInstanceId);
return null;
}
And just to clarify - this does NOT give you access to the tracking data, which are stored in the Monitoring Database. This API is only for the Persistence Database.

Resources