I can successfully retrieve and read emails from Outlook using the following code. How can I delete an email from Outlook? I have tried several ways but couldn't get it to work.
var svc = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
svc.Credentials = CredentialCache.DefaultNetworkCredentials;
svc.AutodiscoverUrl(emailAddress);
EmailMessage email = EmailMessage.Bind(svc, emailMessage.Id, props);
I'm not sure (ie, may be proven incorrect) that you can delete messages using this API. The MSDN article for Microsoft.Exchange.Data.Transport.Email Namespace says this:
The Microsoft.Exchange.Data.Transport.Email namespace contains types that support creating, reading, writing, and modifying e-mail message.
And further inspection of the members available on the EmailMessage class suggest you can access various properties, but there's no "delete" operation/method available.
Depending on your scenario, you might have better luck using a tool like Outlook Redemption which will allow low-level programmatic access to Outlook and/or Exchange (but may not be appropriate if you need to go via exchange web services).
Related
Trying to check if a User has the ManageServer Permission. I've already got the DiscordClientId & DiscordGuildId and the below is designed to get the current users permissions and from there I can specify the permission I'm looking for, but I can't figure it out
var user = userClientId;
var server = guildId;
var userServerPermissions = server.GetPermissions(user);
EDIT: I'm using a HttpWebRequest to get the DiscordClientId and GuildId's for the user when they login via Oauth2, then splitting out the various data I need to get the Id's.
I strongly recommend that you look into using a library for doing this. The one I've always used is Discord.NET, the library you mentioned on your question with the discord.net tag. Another C# discord library I'm aware of is DSharpPlus but I've never tried it.
For Discord.NET I suggest using the nightly/preview versions because they incorporate the recent Discord intents change. Use them by adding https://www.myget.org/F/discord-net/api/v3/index.json to your Nuget package sources.
A library handles everything nicely for you, meaning that you never need to directly send requests to or receive requests from Discord. Read the Discord.NET getting started guide here.
Here's code from Discord.NET which will determine if some user in some guild has the ManageServer permission:
public bool HasManageServerPermission(SocketGuildUser user)
{
return user.GuildPermissions.ManageGuild;
}
I've been looking into using the Graph API from Microsoft to monitor a few online Exchange inboxes.
I was reading their documentation here for Outlook Messages but I'm looking for conversationTopic. I know this is exposed in the normal Outlook Object Model; but I don't see it exposed in their documentation.
Has MS exposed this property in their API?
Info as of 9/15/2016
The conversationThread property has only been exposed in group conversations. It hasn't been exposed in a first class manner for a user's messages. This has been exposed on the beta endpoint via extended properties . You'll want to use the PidTagConversationTopic property.
Here's an example call to get this property (you'll just need to add your message id):
https://graph.microsoft.com/beta/me/messages('YOURMESSAGEID')?$expand=singleValueExtendedProperties($filter=id%20eq%20'String%200x0070')
Here it is for easier reading (no URL encoding):
https://graph.microsoft.com/beta/me/messages('YOURMESSAGEID')?$expand=singleValueExtendedProperties($filter=id eq 'String 0x0070')
I need to be able to access message tracking from Exchange 2010. I would prefer to do this with some sort of api but from the research that I've done I can seem to find anything that hints to the possibility to do this through EWS. The end goal is to count the number of emails sent by account and store the numbers into a seperate business application.
Edit: After looking at the EWS wsdl it looks like there is a FindMessageTrackingReport and GetMessageTrackingReport call. These are not found in EWS Managed API. I'm not sure this is what I'm looking for but I won't know until I get the results back from the API. Is there a way that I can still call this with just a normal web service? Any examples?
Something to the effect of this should work. I didn't have the time to import the proper namespaces, so it may not be perfect.
string querystring = "From:username#example.com Kind:email";
ItemView iv = new ItemView(1000);
FindItemsResults<Item> foundItems = _service.FindItems(WellKnownFolderName.SentItems, querystring, iv);
int count = foundItems.count();
I was able to finally find a solution. It wasn't through EWS but rather a combination of C#, Powershell, and Exchange Management Shell. Here is a link to the EWS Message Tracking Report solution
I'm using Google's .NET Client Library to read email on my gmail account.
But things are not very clear for me.
I'm trying to retrieve Atom feeds with this code.
FeedQuery query = new FeedQuery();
Service service = new Service("mail", "app-MailChecker-1");
service.setUserCredentials(Username, Password);
query.Uri = new Uri("https://mail.google.com/mail/feed/atom");
AtomFeed feed = service.Query(query);
It gives me a simple exception: can't retrieve feed.
My priority is to accomplish this using Google's .NET Client Library
but other options will be helpful as well.
Additional information: this method works for Google Calendar without a problem.
If you read Google's FAQ about the Google Data Protocol you'll see that it has no data API for GMail.
http://code.google.com/intl/nl-NL/apis/gdata/faq.html#GmailAtomFeed
To quote:
Does Gmail have a Data API?
No, but you can use Gmail's Atom feed with AuthSub or OAuth to request
read-only access to a user's unread messages. The scope should be set
to https://mail.google.com/mail/feed/atom/. An example query would be:
GET https://mail.google.com/mail/feed/atom/
If you're interested in managing your mail, Gmail also has IMAP/POP
support.
I experimented with version 1.9.0.0 of the Google Data .NET Client Library myself. Don't see any references to GMail.
Here's one possible approach on how to retrieve the unread messages:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=292
It's similar to what Christian suggested in his comment.
I am using this library IMAPX to get emails.
I also need to send emails but cannot figure out how.
I tried using the example code:
client.Folders["INBOX"].AppendMessage(msg)
but receive an error that AppendMessage requires two arguments and I cannot figure out what the second argument should be.
Is it possible to send an email with this library and if so how?
According to Reflector, it looks like the second parameter should be a string giving the flags for the new message; it looks like the ImapFlags class gives a list of available flags.
If you want more background in IMAP, then you should read its RFC.
However, the IMAP protocol is NOT used to send mail, it's used to read or retrieve mail that's in a mailbox on a server. You can use it to add messages to your own mailbox (as you're trying to do here), but that isn't what most people mean when they talk about sending email... SMTP is the standard way to send email.