ContactEndpoint phone, Lync 2013 - contacts

my application that uses Lync 2013, communicates with a server via websocket, and receives notifications.
These notifications are in Json format, so I convert it to extract a string.
The string is a phone number, and I want to test if one of my contacts are the same phone number to display his name.
My If is always "false".
I wanted to use > and extract the value of DisplayName (phone number as string) but i didn't know how to do it.
This is my code.
foreach (var group in client.ContactManager.Groups)
{
foreach (Contact contact in group)
{
List<object> endpoints = (List<object>)contact.GetContactInformation(ContactInformationType.ContactEndpoints);
List<object> phoneNumbers = endpoints.Cast<object>().Where<object>(N => ((ContactEndpoint)N).Type == ContactEndpointType.HomePhone ||
((ContactEndpoint)N).Type == ContactEndpointType.MobilePhone ||
((ContactEndpoint)N).Type == ContactEndpointType.WorkPhone ||
((ContactEndpoint)N).Type == ContactEndpointType.OtherPhone).ToList();
if (phoneNumbers.ToList().Contains(call.caller))
{
MessageBox.Show(contact.GetContactInformation(ContactInformationType.DisplayName).ToString());
}
}
}

You can ask the contact manager for a contact directly by the number formatted as a tel URL. e.g. "el:12345678"
e.g.
var contact = client.ContactManager.GetContactByUri("tel:" + call.caller);

Related

I would like to setup for an automatic email to be sent to the person who has requested the task via Google Sheets

Good day!
I would like to create a Script on Google Sheets that will take the name (as an ID) from the "Your Name" column and tie it to an email address so that once the "x" on the "Completed" column is added, it will automatically send an alert to the email address of the person who made the request.
Screenshot of the Information collected
(the data is filled in Spanish, my apologies)
This should get you started
function onMyEdit(e) {
const sh = e.range.getSheet();
if(sh.getName() == "Your sheet name" && e.range.rowStart > 1 && e.range.columnStart == 7 && e.value.toLowerCase() == "x") {
GmailApp.sendEmail(e.user.email,"Subject","Message");
}
}
I think it should be an installable onEdit since sending emails requires permission

How do I get more than the default attributes from the Microsoft Graph API when requesting all users?

I am trying to get all users from one AAD tenant with a specified schema extension.
However, when doing this request:
GraphServiceClient client = new GraphServiceClient(new AuthProv(_authHelper.GetAuthenticationResult().Result));
var userList = new List<User>();
var users = await client.Users.Request().GetAsync();
userList.AddRange(users.CurrentPage);
while (users.NextPageRequest != null)
{
var nextPage = users.NextPageRequest.RequestUrl;
Debug.WriteLine("Call To: " + users.NextPageRequest.RequestUrl);
users = users.NextPageRequest.GetAsync().Result;
userList.AddRange(users);
}
I am receiving a JSON object that looks like:
[{"businessPhones":[],"displayName":"some account name","userPrincipalName":"somemail#email.com","id":"123","givenName":null,"jobTitle":null,"mail":null,"mobilePhone":null,"officeLocation":null,"preferredLanguage":null,"surname":null}, ...]
However, I have customized an own attribute for users so I can retrieve values from that, but that attribute is not sent with the API response.
How can I change the request so that all user attributes are retrieved as a reponse?
Use this new baseUrl: "https://graph.microsoft.com/beta/"
GraphServiceClient client = new GraphServiceClient("https://graph.microsoft.com/beta/",new AuthProv(_authHelper.GetAuthenticationResult().Result),null);
It seems that you were using open extensions. If yes, we need to expand the extensions explicitly.
Here is the code to print the value of open extensions for your reference:
foreach (var user in users.CurrentPage)
{
if (user.Extensions != null&& user.Extensions.CurrentPage!=null)
{
var customProperty = user.Extensions.CurrentPage.FirstOrDefault(ext => ext.Id == "Com.Contoso.Deal");
if (customProperty != null)
Console.WriteLine($"{user.UserPrincipalName}--{customProperty.Id}:{customProperty.AdditionalData["companyName"]}");
}
}
while (users.NextPageRequest != null)
{
var nextPage = users.NextPageRequest.RequestUrl;
users = users.NextPageRequest.GetAsync().Result;
foreach (var user in users.CurrentPage)
{
var customProperty = user.Extensions.CurrentPage.First(ext => ext.Id == "Com.Contoso.Deal");
if (customProperty != null)
Console.WriteLine($"{user.UserPrincipalName}--{customProperty.Id}:{customProperty.AdditionalData["companyName"]}");
}
}
If there are multiple pages of open extension, you also should retrieve it via the NextPageRequest. Please feel free to let me know if you still have the problem.

Get SenderEmailAddress from mail item in compose mode

I am retrieving, this mailItem in compose mode, But when I check for the mailItem.SenderEmailAddress, it is NULL, but all other properties have values there (Ex:- body, body format, to, .... ). How I get the sender email FROM THE MAIL-ITEM IT-SELF?
I am using Visual Studio 2013 with Addin express v.7.7.4087
Here is the code :-
Outlook.Inspector currentInspector = null;
Outlook.MailItem mailItem = null;
Outlook.Folder outboxFolder = null;
Outlook.Recipients recipients = null;
const string PR_SMTP_ADDRESS = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E";
currentInspector = Globals.ObjOutlook.ActiveInspector();
if (currentInspector != null)
{
if (currentInspector.CurrentItem is Outlook.MailItem)
{
mailItem = currentInspector.CurrentItem as Outlook.MailItem;
mailItem.Save();
string sender = mailItem.SenderEmailAddress; //This is null
}
}
P.S
I have to deal with multiple mail boxes. so, I can't get current users address using Namespace. It always return me the address of primary mail box user.
Please see following screen shot
Thanks in advance.
Kushan Randima
Are you sending using multiple Exchange accounts? Use MailItem.SendUsingAccount, then read Account.SmtpAddress. If it is "", use Account.CurrentUser.AddressEntry.GetExchangeUser.PrimarySmtpAddress.
If MailItem.SendUsingAccount == null, you can assume the default account.
Use the CurrentUser property of the Namespace class to get the currently logged-on user as a Recipient object. The Address property of the Recipient class returns a string representing the e-mail address of the Recipient.

Custom contact has invalid ContactListId on Windows Universal

I am experiencing some strange behaviour in the Windows Universal Contacts API. Consider the following method:
public async Task TestContactStore()
{
//Fetch store and create custom contact list
ContactStore localStore = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite);
var list = await localStore.CreateContactListAsync("Contact Store Test");
//Create new contact in custom contact list
await list.SaveContactAsync(new Contact() { Name = "Test", LastName = "Contact"});
ContactStore allAccessStore = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly);
//Print all available contact lists
Debug.WriteLine("All Contact Lists");
var contactLists = await allAccessStore.FindContactListsAsync();
foreach (var contactList in contactLists)
{
Debug.WriteLine(contactList.DisplayName + ": " + contactList.Id);
}
//Print all available contacts
Debug.WriteLine("All Contacts");
var contacts = await allAccessStore.FindContactsAsync();
foreach (var contact in contacts)
{
Debug.WriteLine(contact.Name + " " + contact.LastName + ": " + contact.ContactListId);
}
}
It creates a contact list for my app ("Contact Store Test"). Then it saves a new Contact to this list ("Test Contact"). After this it prints all available contact lists and then all contacts.
The output is:
All Contact Lists
Hotmail: 24,5,5
Contact Store Test: 24,11,11
All Contacts
Hotmail Contact: 24,5,5
Test Contact: 24,5,5
Why does the Test Contact show up with the same ContactListId as the Hotmail-list? In the contacts app on the phone it shows up as belonging to the Contact Store Test-list. What am I missing?
I have now done some further research regarding this behavior. In the latest build 10.0.10512.1000, this behavior has changed. All ContactListId return empty string now.
When fetching contacts the way I did in my example above
var contactLists = await allAccessStore.FindContactListsAsync();
foreach (var contact in contactLists)
{
Debug.WriteLine(contactList.DisplayName + ": " + contactList.Id);
}
It seems as though the contacts in the list are always aggregated contacts (even if they are not linked in the address book). Aggregated contacts (apparently) always has empty ContactListId and AggregateId. The Id-property always matches the AggregateId-property of the corresponding raw contacts.
To get the corresponding contact list id, the raw contacts for that aggregate needs to be fetched:
var contactLists = await allAccessStore.FindContactListsAsync();
foreach (var contact in contactLists)
{
var rawContacts = await allAccessStore.AggregateContactManager.FindRawContactsAsync(aggregateContact);
foreach (var raw in rawContacts)
{
Debug.WriteLine(contactList.DisplayName + ": " + contactList.Id);
}
}
This gives expected ContactListId.

Error while trying to use the "reply-to" in google apps script

I'm using google apps script to get the responses of a specific form in an specific e-mail,
What I'm trying to do is use a google form to open support tickets, so people need fill some fields like, title, description and e-mail,
And when they submit the form, it will automatically open a ticket, but the e-mail will be always from the owner of the form, and this was a problem because we want that the person who opened the ticket receives email updates, so what I'm trying to do is this:
I put a field in the form asking the persons email, and I'm trying to put that e-mail into the reply-to...
And apparently I'm in the right way to catch that e-mail but the reply-to don't show the email that the persons filled the box, it appears an error: [Ljava.lang.Object;#34dfe075
Does any one can help me?
Here is my script:
function Initialize() {
var triggers = ScriptApp.getProjectTriggers();
for(var i in triggers) {
ScriptApp.deleteTrigger(triggers[i]);
}
ScriptApp.newTrigger("SendGoogleForm")
.forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
.onFormSubmit()
.create();
}
function SendGoogleForm(e)
{
try
{
var email = "support#email.com";
var form = e.namedValues;
var subject = form["Title"];
var s = SpreadsheetApp.getActiveSheet();
var columns = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
var message = "";
for ( var keys in columns ) {
var key = columns[keys];
if ( e.namedValues[key] && (e.namedValues[key] != "") ) {
message += key + ' :: '+ e.namedValues[key] + "\n\n";
}
}
GmailApp.sendEmail(email, subject, message, {replyTo: form["E-mail"], from: "support#email.com"});
} catch (e) {
Logger.log(e.toString());
}
}
And here is the output of this:
from: support#email.com
reply-to: [Ljava.lang.Object;#34dfe075
to: support#email.com
date: Fri, Oct 17, 2014 at 10:55 AM
subject: New Test
The reply to, is broken :(
The values returned in the e.namedValues property are arrays, so you must access them as such.
Modify your sendEmail line as follows:
GmailApp.sendEmail(email, subject, message, {replyTo: form["E-mail"][0], from: "support#email.com"});
Note the [0] array index on the form["E-Mail"] field, indicating you want the first value in that array, which will be the email address entered.
See the example next to "e.namedValues" here: https://developers.google.com/apps-script/guides/triggers/events#google_sheets_events