I have a client app written using EWS Managed API 1.1. Here's the situation:
The client does not run on a computer within the same domain as the Exchange Server.
I have the username and password of a user, but not their email address.
There's no commonality between username (e.g. ABC123\001234) and email address (e.g. joe.bloggs#company.com).
I can connect to EWS just fine, send messages, etc.
However my software needs to discover the authenticated user's email address, and for various requirements reasons can't just ask the user to provide it.
I assumed I'd be able to get such a simple detail back from the web service, but I'm stumped!
Is this possible for both 2007 and 2010?
Thanks!
You may be able to do it using ExchangeService.ResolveName. I tried it with the following EWS Managed API code example on Exchange 2007 and it worked like a charm:
var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = new Uri("https://serv/EWS/exchange.asmx");
service.Credentials = new NetworkCredential("001234", "PasswordForUser001234", "Domain");
ServicePointManager.ServerCertificateValidationCallback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
{
return true;
};
var resolvedNames = service.ResolveName("001234");
foreach (var resolvedName in resolvedNames)
{
Console.WriteLine(resolvedName.Mailbox.Address);
}
Related
I'm trying to update email categories of items in a Shared Mailbox using Microsoft Graph SDK.
This is the code used to create the Graph SDK Client. It uses the Azure Client Application credentials (ClientId, TenantId, Secret):
var handlers = GraphClientFactory.CreateDefaultHandlers(new DelegateAuthenticationProvider(async msg =>
{
var accessToken = await GetAccessTokenFromCacheOrRefresh(cancellationToken);
msg.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
}));
handlers.Add(_graphLoggingHandler);
var httpClient = GraphClientFactory.Create(handlers);
_graphServiceClient = new GraphServiceClient(httpClient);
This is the code used to update the message categories:
var updatedMessage = new Message();
updatedMessage.Categories = CreateMessageCategories();
await _graphServiceClient.Users[emailAddress].Messages[emailId]
.Request()
.UpdateAsync(updatedMessage, cancellationToken);
When I run this code, I get the error "Access Denied". What permissions do I need to update messages in this Shared MailBox? The Administrators tell me I can't use Mail.ReadWrite on the Application level because that will allow the application to modify emails in all mailboxes.
When the app is configured with application permissions, then the app has access to all mailboxes by default.
Tenant administrators can create an application access policy by using the New-ApplicationAccessPolicy PowerShell cmdlet to limit an app to only specific mailboxes and not all Exchange Online mailboxes in the organization.
More details:
Limiting application permissions to specific Exchange Online mailboxes
I have this working in js to give me the address of the logged-in Metamask user, but I would like to do it using Nethereum. Could someone tell me the equivalent to this with Nethereum?
var accounts = await web3.eth.getAccounts();
console.log(accounts)
This is impossible, because MetaMask is accessible only in the web frontend (JavaScript/TypeScript) and .NET does not run within a web browser.
To get the user address on the server side securely, you need to ask user to sign a message with MetaMask and then extract the address from the message signature.
for Nethereum right now we dont have any direct support that it can access Metamask , so in netherium you can only access account using private key or seed phrase
Like this below
var account = new Account(privateKey);
var publicAddressOfTheAboveAccount = account.Address;
Check the below link if you want to use metamask using Nethereum.Metamask.Blazor to access metamask account instance
checkthislink
Microsoft seems to want to start disabling Basic Auth for Exchange Online and mentioned ending support for EWS protocol
https://techcommunity.microsoft.com/t5/exchange-team-blog/basic-authentication-and-exchange-online-february-2021-update/ba-p/2111904
We're using Microsoft.Exchange.WebServices.2.2 library to get emails from EWS inbox like that:
var service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new NetworkCredential(username, password, domain);
var findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(int.MaxValue));
Is this going to be disabled in the near future? Should we change the way we access emails?
In a desktop application I want to get the current user's email address to use Exchange Web Services auto discovery mechanism as here:
var svc = new ExchangeService()
{
UseDefaultCredentials = true
};
svc.AutodiscoverUrl("user#company.com");
I know the current users domain\username; how do I get the email address before configuring EWS?
You need to use something other then EWS to get that eg LDAP is generally the most common method eg see something like Get UPN or email for logged in user in a .NET web application
Cheers
Glen
I want to send an sms or email automatically in a emergency situation without any user interaction.
The following code helps me in composing the sms or email but need user to tap the send button
private static void SendSms(string mobileNumber)
{
SmsComposeTask smsComposeTask = new SmsComposeTask();
smsComposeTask.To = mobileNumber;
smsComposeTask.Body = "Alert: Save me! My last location was -";
smsComposeTask.Show();
}
private static void SendEmail(string emailAddress)
{
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.To = emailAddress;
emailComposeTask.Subject = "Alert: Save me!";
emailComposeTask.Body = "Please save me my last location was - ";
emailComposeTask.Show();
}
Isn't there any way by which i can by pass the user tap action to send the sms?
Although it's not as easy as using the built-in features, it can be done if you're willing to use web services. For example, twilio will let you send SMS messages for around $0.01/message (there are other SMS services out there so better pricing may be available).
If you're adventurous enough, you could even write your own SMS service that could send messages without the help of 3rd parties (again, not recommended because the ROI likely wouldn't be there unless you were sending a ton of messages).
Sending e-mail via a web service would likely be a simpler solution as it's not hard to write some .NET code that will send e-mail messages for you (when you have the full .NET Framework at your disposal).
Once you have a web service that can send messages for you, it's a simple matter for your phone app to call the service without any user interaction.
It is not possible in Windows Phone. You can prepare an SMS orEmail, but user must be sending it out.