I retrieve an appointment by its unique ID. Now I want to find out which mailbox it is in.
I tried using appointment.Organizer, but this does not work for meetings, or for normal appointments - since appointments can be moved around between mailboxes, the Organizer can be different from the user that has the appointment in his calendar.
Is there a function to get a folder, given only an appointment and an ExchangeService?
If you want to get the SMTP address of the mailbox associated with a particular EWSId one way that should work is using convertId to convert the EWSId to a StoreId and just use generic mailbox address in the Mailbox field then the results you get back (if that ID is good) should contain the Mailbox its associated with eg
String EWSId = "AQMkADY4ZDQ4M2UyLTRhYjItNDhkYy1hMG...";
AlternateId aiRequest = new AlternateId();
aiRequest.UniqueId = EWSId;
aiRequest.Mailbox = "user#mailbox.com";
aiRequest.Format = IdFormat.EwsId;
AlternateId aiResultsStore = (AlternateId)service.ConvertId(aiRequest, IdFormat.StoreId);
Console.WriteLine(aiResultsStore.Mailbox);
Cheers
Glen
Related
My company allows employees to have multiple email addresses in their account.
I am attempting to write an input form where someone can enter any of the emails for a contact and we'll resolve it to the same person.
I've tried doing this via ContactsApp.getContact(email).getPrimaryEmail() to resolve all different inputs to the same primary email, but it doesn't work as expected. Each email I search for returns a different Contact object with only a single email (the one I used to search).
Even if I use ContactsApp.getContact(email).getEmails() to list all emails to the employee, I can see it only returns one at a time.
When going to contacts.google.com, I see the information I expected. Searching for any of the emails will return the same contact, with the same primary email and all other emails listed.
Is there something I'm doing wrong? Or is this how ContactsApp works. If so, is there a workaround?
Thanks!
getPrimaryEmail() will only return an email address if the contact in question has had a default email set and this can only be done via the Google Contacts App, not on the web (go figure).
To solve your problem I would suggest loading all the contacts into an array variable first and then searching this for matching email addresses. I would do the data retrieval on page/view load (so it can be reused without multiple server calls) but have included it all together here for conciseness.
What I found strange about the ContactsApp (and presumable People API too) is that the contacts returned are just empty objects (when logged) with just a bunch of methods on them. However, once you have an array of objects you can write your own properties to those objects for easier access of data.
Therefore I would first of all retrieve all the users contacts, then add a property of .emails to each contact object in the array and then use .some, perhaps, to check if a match appears in .emails (which will also be an array).
Something like:
let strSearch = 'someone#somewhere.net' // EMAIL address to search based on user input
let arrContacts = ContactsApp.getContacts();
let contacts = arrContacts.map(contact => {
let emails = contact.getEmails();
contact.emails = emails.map(email => email.getAddress());
return contact;
});
let foundContact = contacts.filter(contact => contact.emails.some(email => email === strSearch));
Remember .getEmails() returns another array of objects that have the method .getAddress() on them in order to retrieve the actual address, that's why I'm getting an array of email objects with let emails = contact.getEmails(); then using emails.map here to put the actual email addresses into an array stored in the contact.emails property (that doesn't exist so we're actually creating it here).
After that we're filtering the contacts array down to a contact where the searched email address is matched to one of the email addresses in the contact.emails array. I haven't tested it so the last line might need playing around with slightly but I've used something very similar so would expect it to work.
You can then use foundContact[0] to reference the contact found and use the further methods of .getFullname() .getId() etc. to retrieve their data as required. If you need the contacts phone numbers or geographical address that's a whole other process of returning an array of objects using .getPhones() or getAddresses(), but I think that's beyond the scope of this question.
I have a meetings table where I am storing meeting information and where I can select a meeting between 2 types of user visitor type user and host type user. I have a many to many relationships between users and meeting that's why I have a pivot table meeting_user. I need to send mail all of the selected users for one meeting.
I am trying to send email using this but it's storing the meeting_id into notifiable_id column of db. so how can I store users_id in the notifiable_id column of db.
$meetings->save();
$meetings->users()->attach($request->user_id);
$users = Meeting::with('users')->get();
\Mail::to($user->send(New NewMeeting($meetings('id')));
There are two scenarios in which you can send an email to users to the meeting:
When the user has been added to the meeting
When alerting all users (in bulk) of a meeting which they have been added to.
When emailing the user which has just been added
In the event where you would like to email the users once added, you can do the following:
...
$meeting = Meeting::find($meeting_id);
$user = User::find($request->user_id);
$meeting->users()->attach($user->id);
\Notification::send($user, new NewMeetingNotification($user));
This is to be added within code which only adds a user to a meeting, not multiple users.
When emailing all users within a meeting at once
In the event where you would like to email users, in bulk, once you've added all users, you can do the following.
...
$meeting = Meeting::with('users')->where('id', $meeting_id)->first();
$meeting->users()->each(function ($user, $key) {
\Notification::send($user, new NewMeetingNotification($user));
});
$meeting_id being the meeting in question.
Notify User (Optional)
If the user model has the notifiable trait, you can change the code to:
...
$meeting = Meeting::with('users')->where('id', $meeting_id)->first();
$meeting->users()->each(function ($user, $key) {
$user->notify(new NewMeetingNotification($user));
});
I hope this helps.
When I initiate a new instance using boto, I get the reservation ID. But how do I use that reservation ID in the python script?
myreservation = conn.run_instances('ami-999c9999', placement='us-east-1a', key_name='nov15_key',instance_type='m1.xlarge',security_groups=['NuoDB-1-0-1-AutogenByAWSMP-'])
The next line does not work as expected:
myinstanceid = conn.get_all_instances(filters={'reservation-id':myreservation})[0].instances[0]
If I add the reservation ID in the code, it will work without any problem.
myinstanceid = conn.get_all_instances(filters={'reservation-id':'r-1e654a79'})[0].instances[0]
I will like to know what is the type of the reservation id and how to use it.
From the docs, run_instances returns this:
Returns:
The boto.ec2.instance.Reservation associated with the request for machines
Reservation has, also according to the docs, an instances slot which contains a list of boto.ec2.instance.Instance objects. It also has an "id" slot.
If you need the reservation id:
myreservation.id
And if you want the instance id:
myreservation.instances[0].id
So the Reservation object already has all the info you are looking for, no need to do a followup lookup call. But if you need to, you may want to try this:
myinstance = conn.get_all_instances(filters={'reservation-id':myreservation.id})[0]
Or better yet, this:
myinstanceid = conn.get_all_instances(filters={'reservation-id':myreservation.id})[0].id
What is the JSON structure for an invitation, and under what circumstances is one returned. For example,
GET /1/boards/5144051cbd0da6681200201e/invitations?key=[myKey]
always returns an empty array, even after I invite a fake email.
That route no longer returns anything (and should probably be marked deprecated).
Instead of invitation objects, we add a member to the board representing the invited person (where member.memberType = "ghost") so that you can interact with that person (mention in comments, add to cards) before they join Trello. If you invited that person, you will be able to see the 'ghost' member's email address.
I am trying to create Google Contact using Google Contacts API.
According to Google doc(as below), I have already implement the create function.
Google Docs Creating contacts
To create a new contact, send an authorized POST request to the user's contacts feed URL with contact data in the body.
The URL is of the form:
https://www.google.com/m8/feeds/contacts/{userEmail}/full
I use this query to create a contact:
www.google.com/m8/feeds/contacts/{userEmail}/full
However, the new contact is created in the group "Other Contact" by default.
How can I directly create in the group "My Contact"?
Do I need to modify the query?
From the doc (https://developers.google.com/google-apps/contacts/v3/?csw=1#authorizing_requests_to_the_api_name_service):
Contact Group Entry
Contacts can be placed into user-defined groups. You can create,
retrieve, update, and delete these groups using the Contacts Data API,
and you can add contacts to a group or remove contacts from a group.
For details, see the following sections.
The Contacts Data API also provides access to four predefined "system
groups" for each user:
My Contacts Friends Family Coworkers System groups appear in a groups
feed just like user-defined groups do. In fact, system groups are
mostly treated just like other groups. The differences are:
Each system group entry contains a subelement.
The id attribute of that subelement indicates which system group the
group is: Contacts, Friends, Family, or Coworkers. Note that the My
Contacts ID value is simply Contacts, without the "My". Also note
that this system group ID value is different from the group ID given
in the group entry's element. You can't add new system groups,
change the name of a system group, add extended properties to a system
group, or delete a system group. * The contact-group entry
representing a system group doesn't contain a rel="edit" link.
def get_group_id(label_name):
feed = gd_client.GetGroups()
for entry in feed.entry:
if entry.title.text.lower() == label_name:
return entry.id.text
contact_entry = gdata.contacts.data.ContactEntry() #contact_entry
group = get_group_id("My Contact") #group id
membership = gdata.contacts.data.GroupMembershipInfo(href=group) #group membership
contact_entry.group_membership_info.append(membership) # adding group membership to contact_entry
Its not true that contacts can only be placed into user-defined groups. I just experimented with Google Contact V3 API and was able to put a contact under system defined group (My contacts):
ContactEntry contact = new ContactEntry();
Name name = new Name();
final String NO_YOMI = null;
name.setFullName(new FullName("Elizabeth Bennet", NO_YOMI));
name.setGivenName(new GivenName("Elizabeth", NO_YOMI));
name.setFamilyName(new FamilyName("Bennet", NO_YOMI));
contact.setName(name);
GroupMembershipInfo groupInfo = new GroupMembershipInfo();
//You can fetch the following link from GroupEntry#getId()
groupInfo.setHref("http://www.google.com/m8/feeds/groups/{EmailId}/base/{groupId}");
groupInfo.setDeleted(false);
contact.getGroupMembershipInfos().add(groupInfo);
ContactEntry createdContact = myService.insert(new URL(
"https://www.google.com/m8/feeds/contacts/{EmailId}/full"), contact);