Create an outlook link from an item - c#

I'm using Microsoft.Exchange.WebServices to work with some public folders and their items.
I would like to create a View item link to a specific item (Microsoft.Exchange.WebServices.Data.Item), but I can't figure out how to get it's path.
something like:
var theLink =
string.Format(#"Click here", item.XXXX);
Any suggestions?

It seems to not be possible anymore to due security.
Instead I created a link to Outlook Web Access instead.

Related

TFS 2018 API: Can access workitems but not workitem API end point

I created a middleware app that will pull work item data from TFS.
I was able to do this using the workitems end point.
http://sampleserver:8080/tfs/sampleproject/_apis/wit/wiql?api-version=4.0/workitems?ids=1,2,3
Now, I also need to get the work item links per work item. Per docu I would need to access the workitem with expand items. But unfortunately, work item end point does not seem to work.
http://sampleserver:8080/tfs/sampleproject/_apis/wit/wiql?api-version=4.0/workitem/3
Am I missing something here?
According to your description, looks like you just want the URL of created WorkItem, so that anyone when click on URL, created Work Item will be Open.
https://tfsurl:8080/tfs/DefaultCollection/PatrickProject/_workitems/edit/172/
The URL should be above format and here DefaultCollection is the collection name and the PatrickProject is the project name. I used this url and got rid of the id '172' in this case and use the ID of newly created work item. This would return the URL to go to the work item HTML page.
So it's a fixed format, if you have Newly Created WorkItem ID and collection name , project name, you just need to follow above format and change the last value of work item ID. That's it , ignore of which work item type you created.
If you want do this with code, do not use Rest API, you need to use client API, sample snippet:
var tfsURI = new Uri("http://test:8080/tfs");
var networkCredential1 = new NetworkCredential("test", "test!");
ICredentials credential = (ICredentials)networkCredential1;
Microsoft.VisualStudio.Services.Common.WindowsCredential winCred = new Microsoft.VisualStudio.Services.Common.WindowsCredential(credential);
VssCredentials vssCredentials = new VssCredentials(winCred);
using (TfsTeamProjectCollection collection = new TfsTeamProjectCollection(tfsURI, vssCredentials))
{
collection.EnsureAuthenticated();
TswaClientHyperlinkService hyperlinkService =
collection.GetService<TswaClientHyperlinkService>();
String TFSurl = hyperlinkService.GetWorkItemEditorUrl(17648).ToString(); //17648 WorkItem ID
}
Hope this Helps!
To get specific work item information you need to use the Get Workitem API call so try http://sampleserver:8080/tfs/sampleproject/_apis/wit/workitems/3?api-version=4.0 instead.
You can also use this http://sampleserver:8080/tfs/sampleproject/_apis/wit/workitems/3?$expand=Links&api-version=4.0 and this will return the work with Id of 3 and all it's links (parent, attached files, changetset, etc.)
Notice that the api-version=4.0 with change depending on the version of TFS/Service you are using and should always be the last string in the REST call.

Accessing 2nd exchange inbox from Outlook 2013 using VSTO

Getting default inbox works like the following:
_outlookNameSpace = this.Application.GetNamespace("MAPI");
_inbox = _outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
Now on the same lines, how do get the inbox for the other exchange account say "abc#corp.com" ?
Thanks in advance.
Assuming the second mailbox is already in the profile, you need to find the appropriate account in the Namespace.Stores collection and call Store.GetDefaultFolder.
Otherwise you can call Namespace.GetSharedDefaultFolder.
I have a similar situation, where the 2nd account is identified by its .DisplayName property, which can be set in Account Setup. To find the Account, use:
var account = Globals.Addin.Application.GetNamespace("MAPI")
.Accounts.Cast<Account>()
.FirstOrDefault(a => a.DisplayName == "TargetDisplayName");
Then use Account.DeliveryStore to get access to the store and find the folder. .GetDefaultFolder gives you the folder:
DraftsFolder = (Folder) account.DeliveryStore.GetDefaultFolder(OlDefaultFolders.olFolderDrafts);

Manipulate umbraco content using a console application

This is a noob question but I'm searching for some time and can't find any useful information.
I need to develop a rotine (console application) that will read and write content into a umbraco site. I've already read that you can do that with web forms and mvc application.
But I need to use umbraco like an external source. I need to do something like we do with Word documents. For example: open the file, read the file, write some things and save it.
I've already installed the API using
PM> Install-Package UmbracoCms -Pre
Some things I've already read:
http://nishantwork.wordpress.com/2012/09/27/umbraco-create-custom-content-node-in-umbraco-by-c/
https://github.com/sitereactor/umbraco-console-example
What is the best to achieve that? I don't know how to do it exactly...
You can create an Umbraco node (document), write to it and save it from a console application. Umbraco is basically a bunch of .Net libraries:
//Get the type you would like to use by its alias and the user who should be the creator of the document
DocumentType dt = DocumentType.GetByAlias("Textpage");
User author = User.GetUser(0);
//create a document with a name, a type, an umbraco user, and the ID of the document's parent page. To create a document at the root of umbraco, use the id -1
Document doc = Document.MakeNew("My new document", dt, author, 1018);
// Get the properties you wish to modify by it's alias and set their value
doc.getProperty("bodyText").Value = "<p>Your body text</p>";
doc.getProperty("articleDate").Value = DateTime.Now;
//after creating the document, prepare it for publishing
doc.Publish(author);
//Tell umbraco to publish the document
umbraco.library.UpdateDocumentCache(doc.Id);
See:
http://our.umbraco.org/wiki/reference/api-cheatsheet/creating-a-document
http://our.umbraco.org/wiki/reference/api-cheatsheet/modifying-document-properties
Just to help anyone with the same issue. I'm find out a web service in umbraco and i'm currently using that (until now for reading information only, but as far as I know we can write infomation also). Altought there's little documentation is easy to use.
But to use that you need to set <webservices enabled="False"> in umbracoSettings.config . This fie is in the folder Config inside umbraco.
We have to set user rights into the webservices node also to allow the user to use the web service
DocumentServiceReference.documentServiceSoapClient client = new DocumentServiceReference.documentServiceSoapClient();
client.WebservicesEnabled();
DocumentServiceReference.ArrayOfDocumentCarrier documents = client.readList(parentId, username, password);
foreach (DocumentServiceReference.documentCarrier doc in documents)
{
DocumentServiceReference.ArrayOfDocumentProperty properties = doc.DocumentProperties;
foreach (DocumentServiceReference.documentProperty property in properties)
{
string key = property.Key;
string value = property.PropertyValue.ToString();
}
}

How to add discussion board in page automatically in Sharepoint 2010?

We create a discussion board in Sharepoint 2010 without much effort, but I am looking for a solution where discussion board and all its replies are added to the certain zone automatically. That is end user do not need to add discussion board, through the process of entering page into edit mode and then adding web part. But instead, once user create a discussion board, all discussions and message are added to the page automatically (to certain zone in page).
Thanks.
Add this code the a web event handler (ListAdded) in order to run this code automatically. In that code you will need to check if the list type is of Discussion. In the event receiver you will need get a reference to the SPWeb in which you want to add the web part, and to the list you want to use (in this example the Contacts list). Next you create an instance of the ListViewWebPart class, in which you can set the ZoneID, the ListName and the ViewGuid. This is the tricky part, the ListName property should contain the ID of your list (a GUID), not the name of your list!! But the ListName property is of the type string, so you need to convert the List GUID to a string using .ToString(“B”).ToUpper(). The same goes for the ViewGuid. Finally you need to get a reference to the WebPartCollection for the page in which you want to add the web part (in this example the home page, being default.aspx). Now you can add the web part using the Add method.
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;
// Get a reference to a web and a list
SPSite site = new SPSite("http://localhost:8000");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Contacts"];
// Instantiate the web part
ListViewWebPart wp = new ListViewWebPart();
wp.ZoneID = "Left";
wp.ListName = list.ID.ToString("B").ToUpper();
wp.ViewGuid = list.DefaultView.ID.ToString("B").ToUpper();
// Get the web part collection
SPWebPartCollection coll =
web.GetWebPartCollection("default.aspx",
Storage.Shared);
// Add the web part
coll.Add(wp);

Add items to existing SharePoint lists by coding

I want to add items to a still existing SharePoint list by self-coding.
So I searched the internet and found a lot of information how to create lists, add items and so on..
SPWeb mySite = SPContext.Current.Web;
SPListItemCollection listItems = mySite.Lists[TextBox1.Text].Items;
SPListItem item = listItems.Add();
The coding seems easy, but where i have to put the code?
I programmed Web Parts and deployed these to my web application.
This was no problem, but here i am missing an approach.
I am using VisualStudion 2008 and SharePoint WSS 3.0
Thank you for any help.
SPWeb app = SPContext.Current.Web;
SPList ListName = app.Lists["YourListName"];
SPListItem ListItem = ListName.Items.Add();
ListItem["field1Name"] = value;
ListItem["field2Name"] = value;
ListItem.Update();
It depends on the purpose - why are you doing this?
Do you have one specific list where you (as the owner/administrator) need to create items and this has to be done only once? If yes, then you can do it with Powershell, as in this Karine Bosch's post.
If you need your users to be able to add items to list using program code, then web parts is the way to go. Then you will want to build a nice user interface for that webpart. And then you can deploy your webpart to your server, create a page in your site and add the webpart to the page.
If you need to create the new list item as soon as something else happens (for instance, a list item is created in some other list, then think of event handlers.
you are doing some modification on site ...so after that we need to update the site ..Use ListItem.update();

Categories