How to get smtp address of current Outlook store - outlook

We have user with 3-4 shared email address in Outlook.
I am developing add-in where it will extract the email address of selected store and will get it's contact folder from People.
My problem is I don't know how to get email address of SelectedStore.
Here is my code.
string recipientName = SelectedStore.EmailAddress; // This is what I want to make it work
Outlook.Recipient recip = ns.CreateRecipient(recipientName);
recip.Resolve();
if (recip.Resolved)
{
Outlook.MAPIFolder folderContacts = ns.GetSharedDefaultFolder(recip, Outlook.OlDefaultFolders.olFolderContacts);
}
Any help will be appreciated.
Thank you.

For the mailbox owner, you can either try to read the MAPIFolder.Store property to get to the parent store, then read the PR_MAILBOX_OWNER_ENTRYID property (DASL name "http://schemas.microsoft.com/mapi/proptag/0x661B0102") using Store.PropertyAccessor.GetProperty. You can then use the store owner entry id to call Namespace.GetAddressEntryFromID. Once you have the AddressEntry object, you can use AddressEntry.GetExchangeUser.PrimarySmtpAddress.
Note that PR_MAILBOX_OWNER_ENTRYID property is only available in the online stores. You might want to use Redemption (I am its author) and its RDOExchangeMailboxStore.Owner.SmtpAddress property. RDOExchangeMailboxStore can be retrieved using RDOSession.GetRDOObjectfromOutlookObject(Store) or using RDOSession.GetStoreFromID.
You can also try to retrieve the store entry id and parse it - its format is documented and you can extract the EX type address of the owner. You can then construct the GAL entry id to open the AddressEntry object. From there, you can retrieve the SMTP address.

Just to let you know, I found the solution.
Outlook.MAPIFolder folderContacts = store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
should do the trick.

Related

How to enumerate values of custom user property in Outlook C#

I have created custom user property in Outlook called "Ownership". When someone from the team claim ownership of an email, person's name is saved as its value.
My question, is there any way to enumerate all the values of this custom property into combo box.
In simple words, get a list of all team members names (whoever has claimed ownership of an email in inbox folder).
I want to do something like this.
Outlook.UserDefinedProperties userDefinedProperties = null;
Outlook.UserDefinedProperty userDefinedProperty = null;
Outlook.MAPIFolder currentFolder = application.ActiveExplorer().CurrentFolder;
mailUserProperties = currentFolder.UserDefinedProperties;
mailUserProperty = mailUserProperties["Ownership"];
// Filling up the combo box
PersonCombo.Items.Add(userDefinedProperty.Value);
I want to use current folder because folder will have all the values while an email can only have one value of the custom property.
If this is not possible, is there any other way to get it done?
Thank you in advance.
There isn't a single query that will return all unique values of a particular named property. The best you can do is search for all items where the property exists (not null), and then build a list of unique values.
I do not think, however, this is a good of storing possible values - it really must be a single source, such as a particular GAL distribution list, or a hidden (associated) message in the folder that stores all possible values in a single property.
Thanks everyone for your input.
At the end, I ended up creating GAL distribution list as Dmitry suggested and used it for my purpose.

How to get current login user

I want to get current login user via EWS. I search some document, but I don’t find a method to get current user. I need your help. Thanks very much
Use ResolveName EWS operation - you will only need the user's SMTP address.
As Dmitry said, you could use ResolveName. For example:
NameResolutionCollection ncCol = service.ResolveName("user#domain.com",ResolveNameSearchLocation.DirectoryOnly,true);
Console.WriteLine(ncCol[0].Contact.DisplayName);
You could also use ConverId with a generic address to get the current user’s own email. For example:
Folder Inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
AlternateId aiAlternateid = new AlternateId(IdFormat.EwsId, Inbox.Id.UniqueId, "mailbox#domain.com");
AlternateIdBase aiResponse = service.ConvertId(aiAlternateid, IdFormat.EwsId);
Console.WriteLine(((AlternateId)aiResponse).Mailbox);
AutoDiscover will also return the PrimarySMTP address of a Mailbox as you do a POX based discovery.

Is it possible to send emails programmatically to a PHPList list?

I am looking for a solution to send automated emails from my website to PHPList lists. From my understanding, PHPList's emails are authored manually using the web-based interface provided by the application. Are there some APIs I can use to allow my website to send emails directly?
You can just code one like this, just need to change some of the values on the insert strings to match your list. So when someone creates and account on your website, you just call a routine like this and insert it into PHPLIST.
You can also do it with a trigger on your members table. The code below is VB.NET - but you can easily convert it to php.
Public Sub AddMemberToPHPList(ByVal vUserEmail As String)
Dim moConn As MySqlConnection
moConn = New MySqlConnection("server=*********;User Id=******;Password=*******;Persist Security Info=True;database=phplist;Ssl Mode=None;Allow User Variables=True;")
moConn.Open()
Dim oMySqlCommand As New MySqlCommand
oMySqlCommand.Connection = moConn
oMySqlCommand.Parameters.AddWithValue("email_address", vUserEmail.ToLower)
oMySqlCommand.Parameters.AddWithValue("uniqid", Guid.NewGuid)
oMySqlCommand.CommandText = "INSERT IGNORE INTO phplist_user_user set email = ?email_address, confirmed=1,entered = now(),modified = now(),uniqid = ?uniqid,htmlemail = 1, bouncecount=0,disabled = 0"
oMySqlCommand.CommandType = CommandType.Text
oMySqlCommand.ExecuteNonQuery()
oMySqlCommand.CommandText = "INSERT IGNORE INTO phplist_listuser set userid = (select id from phplist_user_user where email = ?email_address) , listid = 3, entered = now(), modified= now()"
oMySqlCommand.ExecuteNonQuery()
End Sub
first, if is a list of emails, yo need use queues, you only need have the emails stored in a database, and then sending through queues with a cicle of the emails of the database
This reply is rather late I realize, but I think you'd do well to look into this plugin for PHPList:
https://resources.phplist.com/plugin/submitbymail
The plugin page says that the author is no longer supporting/developing the plugin, but the code that is there should work on current versions of PHPList.
I used to use an older plugin (called 'MailToList') for this exact purpose - someone can compose an email somewhere else, send it to a specific address on their system, and then the plugin watches those email inboxes for new emails and will queue up a new 'campaign' using that email as the source. So you essentially have to set up one email inbox for each list you want to send out to in PHPList.
(I'm just going through an upgrade process on my PHPList system and will probably use this 'SubmitByMail' plugin since the 'MailToList' plugin appears to not exist any more. But I haven't yet actually used the 'SubmitByMail' plugin.)

Outlook Add-In : Get Contact from Mail

I am doing a bit add-in development for outlook 2010 and I'm trying to get the ContactItems associated to an email (MailItem). I think the MailItem.Links collection should return what I want, but it's empty. Maybe I'm on the wrong path, but I'm out of ideas at the moment.
I have an Outlook.MailItem and I like to get the associated Outlook.ContactItem. When you open a mail with outlook and hover over the mail-adresses a contact-popup appears, so the link must be somewhere in the MailItem, but I don't know where.
For example, I tried using the MailItem.Links collection which says in tooltip that it represents the contacts to which the item is linked.
Explorer explorer = application.ActiveWindow() as Explorer;
MailItem mail = explorer.Selection as MailItem;
foreach (Link l in mail.Links)
{
System.Diagnostics.Debug.WriteLine("Link: " + l.Name);
}
The MailItem so far is correct, I can do whatever I want with it but
the MailItem.Links collection is empty.
You should try using the MailItem.Recipients collection which contains the addresses where the message will or has been be sent to (i.e. To, CC, BCC). You will have to check the Recipient.AddressEntry to see if the address exists in the Contacts Address Book (CAB) via GetContact, otherwise you will have to resolve it using ExchangeUser via GetExchangeUser.
The AddressEntry.AddressEntryUserType will tell you what type of recipient is included in the message - Exchange User or List, CAB, or basic SMTP address.

Launcher and Chooser in Windows Phone 7

I am not able to find a way (even with Mango SDK) in which I can show a chooser (say PhoneNumberChooserTask), and get all details about a contact...
Only Name and PhoneNumber is available. For other information like address, I have to use a different chooser. Is there any way in which I can show a chooser (anyone) and get all details...
Phone number
Email address
Photo of the contact
etc.
let me clarify the issue here...
The following code will not work. I want to show a chooser in such a way that it grabs all details. Showing multiple choosers, as I said is not what I want. Imagine asking someone to choose the same contact 3 times to get Email, PhoneNumber and Address.
EmailAddressChooserTask ect = new EmailAddressChooserTask();
ect.Completed += new EventHandler<EmailResult>(ect_Completed);
ect.Show();
PhoneNumberChooserTask pct = new PhoneNumberChooserTask();
pct.Completed += new EventHandler<PhoneNumberResult>(pct_Completed);
pct.Show();
AddressChooserTask act = new AddressChooserTask();
act.Completed += new EventHandler<AddressResult>(act_Completed);
act.Show();
In v7.1 (Mango) you can use the Contacts class. You can use the SearchAsync method providing whatever search criteria you want (DisplayName is the most likely) and then handle the SearchCompleted event and use the ContactsSearchEventArgs.Results to access the returned Contact objects.
From there, you can use the GetPicture method to retrieve the contact image, and the various properties of the Contact object to access all the other information.
Hopefully that will get you started. You can find more information in the Microsoft.Phone.UserData namespace.
I think you can do this with the following tasks:
AddressChooserTask
EmailAddressChooserTask
PhoneNumberChooserTask

Resources