I have made a Outlook Addin Angular8 Application using Office.js to interact with Outlook.
Everything works fine, the Addin works fine and stores a CustomPropertie to the Mailitem which can be read after reopening the Mailitem.
In this Implementation this is a simple hashmap.
this.customPropertiesContainer.set('lvAppointmentServiceId', this.selfiId);
this.customPropertiesContainer.saveAsync();
Now I want to read the Propertie in another Application using EWS to get the Mail Item.
Here the Implementation is very complex.
private PropertySet getPropertySetKnown() {
PropertySet propertySet = null;
try {
propertySet = new PropertySet(BasePropertySet.FirstClassProperties, getExtendedPropertyDefinition());
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return propertySet;
}
private ExtendedPropertyDefinition getExtendedPropertyDefinition() throws Exception {
ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(
DefaultExtendedPropertySet.PublicStrings, CATERING_JIRA_ID, MapiPropertyType.String);
return extendedPropertyDefinition;
}
Item boundItem = Item.bind(this.exchangeService, appointmentId, getPropertySetKnown());
jiraCateringId = boundItem.getExtendedProperties().getItems().stream()
.filter(property -> property.getPropertyDefinition().getName().equals(CATERING_JIRA_ID)).findFirst()
.orElse(null);
Does anyone know in which DefaultExtendedPropertySet the Propertie could be found set by Office.js ?
Is there a way to get all Propertis using EWS with no need to define an own Definition?
Is there any Debug Tool in Outlook / Exchange to see the Customproperties in an Item?
As mentioned by #Glen Scales this should answer your question.
Also you can refer the doc Working with extended properties for more details on accessing extended properties from EWS.
Related
I am using Outlook Object model (Interop) for my softawre.
Before I send email, I get and keep the PR_SEARCH_KEY of the email that we created.
If I want to find the email in sent folder using PR_SEARCH_KEY, how can I do that in c# using Office.Interop (not EWS or not redemption)?
I tried to find it from SentFolder.Items.Find(filter). But it does not work as the PR_SEARCH_KEY is binary.
Thanks !
public Outlook.MailItem FindEmailFromSentFolder(string emailId)
{
try
{
if (_sentFolderItems == null)
return null;
// find the sent mail from sent folder based on PR_Serach_Key
var filter = string.Format("#SQL=\"http://schemas.microsoft.com/mapi/proptag/0x300B0102\" = '{0}'",
emailId);
var item = _sentFolderItems.Find(filter);
if (item != null && item is Outlook.MailItem)
return item as Outlook.MailItem;
}
catch (Exception ex)
{
return null;
}
return null;
}
As you already noticed, OOM won't let you search for any binary property - you will need Extended MAPI (C++ or Delphi) or Redemption (any language).
Your best bet is to set some string property on the outgoing message and then look for it in the Sent Items folder.
Hello Im updating a UWP app that we use in ouroffice.
Before when we use it to send email it uses the Windows.ApplicationModel.Email.EmailMessage however this i really limited. So i would like to use Microsoft.Office.Interop.Outlook instead to create the email directly with outlook
My test code looks like this.
try
{
List<string> lstAllRecipients = new List<string>();
//Below is hardcoded - can be replaced with db data
lstAllRecipients.Add("info#test.com");
//lstAllRecipients.Add("chandan.kumarpanda#testmail.com");
Outlook.Application outlookApp = new Outlook.Application();
Outlook._MailItem oMailItem = (Outlook._MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
Outlook.Inspector oInspector = oMailItem.GetInspector;
// Thread.Sleep(10000);
// Recipient
Outlook.Recipients oRecips = (Outlook.Recipients)oMailItem.Recipients;
foreach (String recipient in lstAllRecipients)
{
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(recipient);
oRecip.Resolve();
}
////Add CC
//Outlook.Recipient oCCRecip = oRecips.Add("THIYAGARAJAN.DURAIRAJAN#testmail.com");
//oCCRecip.Type = (int)Outlook.OlMailRecipientType.olCC;
//oCCRecip.Resolve();
//Add Subject
oMailItem.Subject = "Test Mail";
// body, bcc etc...
//Display the mailbox
oMailItem.Display(true);
}
catch (Exception objEx)
{
await new MessageDialog(objEx.Message, "Error email to Outlook").ShowAsync();
}
I have added the Microsoft.Office.Interop.Outlook.dll version to the app by finding it in C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Outlook\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Outlook.dll it is file version 15.0.4569.1507
My problem is when i run the code i get the following error
Creating an instance of the COM component with CLSID {0006F03A-0000-0000-C000-000000000046} using CoCreateInstanceFromApp failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). Please make sure your COM object is in the allowed list of CoCreateInstanceFromApp.
I guees i have to add a reference in the appxmanifest how ever i cannot figure out what.
I am developing an UWP Application , i want to add a Attachment to outlook from UWP app programmatically
Request you to please me know if any alternatives are there.
Looking forward for your response.
You can use the share contract to send some data to the compliant applications (including outlook). It allows you to share some text and data with any compliant apps.
To activate the sharing, you just need to register to the DataRequested event and show the share UI:
DataTransferManager.GetForCurrentView().DataRequested += OnDataRequested;
DataTransferManager.ShowShareUI();
Then, in the event handler:
private async void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
var deferral = args.Request.GetDeferral();
try
{
args.Request.Data.Properties.Title = "Share Title"
args.Request.Data.Properties.Description = "Share some data/file";
var file = await ApplicationData.Current.TemporaryFolder.GetFileAsync("myFileToShare.xxx");
args.Request.Data.SetStorageItems(new IStorageItem[] { logFile });
}
catch
{
args.Request.FailWithDisplayText("Unable to share data");
}
finally
{
deferral.Complete();
sender.DataRequested -= OnDataRequested;
}
}
Once done, the system will show the share UI where the user will be able to select the app he want. This app will receive the sent data.
While #Vincent's answer is perfect when you want to use Share Contract, if you want to use Just Email and attach the File, Below is a simple Method that i use in one of my App.
internal async void ShowEmail(string body, string subject, StorageFile attachment)
{
EmailMessage email = new EmailMessage();
email.Subject = subject;
email.Body = body;
var stream = RandomAccessStreamReference.CreateFromFile(attachment);
email.SetBodyStream(EmailMessageBodyKind.Html, stream);
await EmailManager.ShowComposeNewEmailAsync(email);
}
Above method is a strip down of the example from Here
I am currently working in Enterprise Java and I'm a newbie. I am trying to create a method which should delete a selected item from a data table. My project contains Graphical User Interface elements from "http://www.primefaces.org/showcase/".
The deletion is made through a web-service.
This is the method I created so far:
public boolean delete(String articleId) {
Client client = ClientBuilder.newClient();
WebTarget target
= client.target(DELETE_URL);//this is a String
//TODO call ws method delete
try{
target.request()....;
} catch(Exception ex) {
LOGGER.error("Delete Article Error ", ex);
}
return true;
}
Could you tell me how can I handle the deletion in an appropiate way?
All the best!
In your case the following should do the trick.
target.request().delete(Response.class)
In the SDK Javadoc, the Community class does not have a "setParentCommunity" method but the CommunityList class does have a getSubCommunities method so there must be a programmatic way to set a parent Community's Uuid on new Community creation. The REST API mentions a "rel="http://www.ibm.com/xmlns/prod/sn/parentcommunity" element". While looking for clues I check an existing Subcommunity's XmlDataHandler's nodes and found a link element. I tried getting the XmlDataHandler for a newly-created Community and adding a link node with href, rel and type nodes similar to those in the existing Community but when trying to update or re-save the Community I got a bad request error. Actually even when I tried calling dataHandler.setData(n) where n was set as Node n=dataHandler.getData(); without any changes, then calling updateCommunity or save I got the same error, so it appears that manipulating the dataHandler XML is not valid.
What is the recommended way to specify a parent Community when creating a new Community so that it is created as a SubCommunity ?
The correct way to create a sub-community programatically is to modify the POST request body for community creation - here is the link to the Connections 45 infocenter - http://www-10.lotus.com/ldd/appdevwiki.nsf/xpDocViewer.xsp?lookupName=IBM+Connections+4.5+API+Documentation#action=openDocument&res_title=Creating_subcommunities_programmatically_ic45&content=pdcontent
We do not have support in the SBT SDK to do this using CommunityService APIs. We need to use low level Java APIs using Endpoint and ClientService classes to directly call the REST APIs with the appropriate request body.
I'd go ahead and extend the class CommunityService
then go ahead and add CommunityService
https://github.com/OpenNTF/SocialSDK/blob/master/src/eclipse/plugins/com.ibm.sbt.core/src/com/ibm/sbt/services/client/connections/communities/CommunityService.java
Line 605
public String createCommunity(Community community) throws CommunityServiceException {
if (null == community){
throw new CommunityServiceException(null, Messages.NullCommunityObjectException);
}
try {
Object communityPayload;
try {
communityPayload = community.constructCreateRequestBody();
} catch (TransformerException e) {
throw new CommunityServiceException(e, Messages.CreateCommunityPayloadException);
}
String communityPostUrl = resolveCommunityUrl(CommunityEntity.COMMUNITIES.getCommunityEntityType(),CommunityType.MY.getCommunityType());
Response requestData = createData(communityPostUrl, null, communityPayload,ClientService.FORMAT_CONNECTIONS_OUTPUT);
community.clearFieldsMap();
return extractCommunityIdFromHeaders(requestData);
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.CreateCommunityException);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.CreateCommunityException);
}
}
You'll want to change your communityPostUrl to match...
https://greenhouse.lotus.com/communities/service/atom/community/subcommunities?communityUuid=2fba29fd-adfa-4d28-98cc-05cab12a7c43
and where the Uuid here is the parent uuid.
I followed #PaulBastide 's recommendation and created a SubCommunityService class, currently only containing a method for creation. It wraps the CommunityService rather than subclassing it, since I found that preferrable. Here's the code in case you want to reuse it:
public class SubCommunityService {
private final CommunityService communityService;
public SubCommunityService(CommunityService communityService) {
this.communityService = communityService;
}
public Community createCommunity(Community community, String superCommunityId) throws ClientServicesException {
Object constructCreateRequestBody = community.constructCreateRequestBody();
ClientService clientService = communityService.getEndpoint().getClientService();
String entityType = CommunityEntity.COMMUNITY.getCommunityEntityType();
Map<String, String> params = new HashMap<>();
params.put("communityUuid", superCommunityId);
String postUrl = communityService.resolveCommunityUrl(entityType,
CommunityType.SUBCOMMUNITIES.getCommunityType(), params);
String newCommunityUrl = (String) clientService.post(postUrl, null, constructCreateRequestBody,
ClientService.FORMAT_CONNECTIONS_OUTPUT);
String communityId = newCommunityUrl.substring(newCommunityUrl.indexOf("communityUuid=")
+ "communityUuid=".length());
community.setCommunityUuid(communityId);
return community;
}
}