C# create a new exchange email with properties like deliverydate - c#

I'm looking for exchange email creation for a migration lotus to exchange platform.
I can create email body with Body property of an EmailMessage Object, but I can only Get DateTimeCreated property and not set it.
What I want, is to get my lotus email, convert it to exchange format with all properties, and save it to my exchange server.
regards

Related

Get "send as" or "on behalf of" information from Exchange server

As we know, there is a permission you can grant on the Exchange server that allows a user (foo) to send email in the name of as the permission granter (bar).
On behalf of -> From: foo#baz.qux on behalf of bar#baz.qux
Send as -> From: bar#baz.qux
How the from field appears in the recipient’s email is controlled by the Exchange - as soon as the mail passes the Exchange the corresponding fields are set.
Send as -> "from: bar#baz.qux".
On behalf of -> "from: bar#baz.qux" and "sender: foo#baz.qux".
Now it comes to my question:
Is there a way to get the Exchange rule which controls the appearance for the recipient? For example, via the MAPI interface or Exchange Web Service?
When Outlook sends on behalf of a user, about half dozen PR_SENT_REPRESENTING_xyz MAPI properties are set, email address and name are always included - you can see these properties in OutlookSpy (I am its author) - click IMessage button.
When you use MailItem.SentOnBehalfOfName property in OOM, you can only set the name (which can be a problem if the name is ambiguous). But when the message goes out, name name will be resolved, the PR_SENT_REPRESENTING_xyz MAPI properties will be set.

How to forward emails from SendGrid

Overview:
Our use case involves using the SendGrid Inbound Parse to accept, record and process emails. We also need those emails to be forwarded to our ticketing system (i.e. Zoho Desk).
We would really like to be able to forward the unedited email to Zoho Desk, preserving the original From, To, etc.
Problem(s):
When we try to forward the email using SendGrid's SMTP server, and using the MimeKit.MimeMessage.ResentTo("emailchannel#account.zohodesk.com") option, SendGrid is rejecting the forward request because of "Sender Authentication". The error we're getting from SendGrid is:
The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements.
Below is the code we're using:
SmtpClient cli = new SmtpClient();
cli.Connect(_config["SendGrid:Server"], int.Parse(_config["SendGrid:Port"]), true);
cli.Authenticate(_config["SendGrid:Username"],_config["SendGrid:ApiKey"]);
message.ResentSender = null;
message.ResentFrom.Clear();
message.ResentReplyTo.Clear();
message.ResentTo.Clear();
message.ResentCc.Clear();
message.ResentBcc.Clear();
message.ResentFrom.Add(MailboxAddress.Parse(_config["SendGrid:From"]));
message.ResentReplyTo.AddRange(message.ResentFrom);
message.ResentTo.AddRange(from o in matches
select MailboxAddress.Parse((string)o.ticket_addr));
message.ResentMessageId = MimeUtils.GenerateMessageId();
message.ResentDate = DateTimeOffset.Now;
cli.Send(message);
Question(s):
Is there a way with SendGrid we can forward the inbound email to Zoho Desk while preserving the From fields?
I would imagine SendGrid isn't the only company requiring Sender Authentication, as such, how else can we forward unedited emails to a ticketing platform?
Twilio SendGrid developer evangelist here.
SendGrid does require you to verify, via Single Sender Verification or Domain Authentication, email addresses from which you wish to send emails. So you cannot use SendGrid to automatically forward keeping the from email intact.
I have a couple of ideas about workarounds here though.
You could forward from your verified email address and add the original from email address in a reply-to field. I haven't worked with Zoho Desk, but perhaps you could configure it to respect that field instead of from.
Zoho has a guide on how to set up forwarding from various inboxes. Could you host your email with one of those providers and forward incoming emails onto Zoho and to your SendGrid email address for this processing?

How to send invitation to google calender from gmail in ASP.NET MVC 5?

I have already written a code in C# to send a mail to the user from my gmail and also sending a attachment if it contains. Now I need to send the invitation so that it marks on customer google calendar.My code for sending a gmail and attachment is :
public static void SendEmail(MessageModel message)
{
string from = "noreply#test.com";
if (string.IsNullOrEmpty(from)) {
throw new System.Exception("Invalid email configuration ! Missing SupportEmailAddress in Web.config.");
}
SmtpClient client = new SmtpClient();
MailMessage mailMessage = new MailMessage(from,
message.Destination,
message.Subject,
message.Body)
{
IsBodyHtml = true
};
if (message.Attachment != null)
{
Attachment attachment = new Attachment(message.Attachment, MediaTypeNames.Application.Octet);
mailMessage.Attachments.Add(attachment);
}
client.Send(mailMessage);
}
The above code works fine for sending a message and attachment to the user. Now I need to send invitation to them in so that it marks on their google calender. How can I do this?
The thing is i think you may be going about this in the wrong way. You should consider looking into the Google Calendar API. By doing a Event.insert directly into your calendar there by creating a new event. You can then do a event.update and update the event adding more attendees to the event as you so choose and they will automatically (if you choose to) be notified of invites by google.
The issue here being controlling the event itself. I would recommend looking into using a service account. You can grant the service account access to your calendar and it will be able to insert and update these events. The only drawback to this solution will be the emails sent to users notifying them of the event invite.
invite will come from the service accounts email address which is ugly.
service account invites sending notification emails seams to be buggy lately.
Second option would be to do something like an installed application where by you use Oauth2 authenticate your application once and store the refresh token the application will then pretend to be you and write to the event when ever it needs to.
refresh tokens can expire very very rarely but you still should check for this error.
invites are sent from you so you will be giving everyone your email address.
A bit of sample code for you. Google .net samples

Sending mail from website in ASP.NET

I coded a website contact form with mail send and after dozens of research cannot find an answer hoping stackoverflow users can help.
The aspx.cs file signs into the specified gmail configuration to send the email HOWEVER is there a way to set the SENDER as what the user inputs in the email textbox, so instead of recieving the email from myself so when clicking "Reply" on the mailbox its not replying to myself? If that makes sense?
So the sender is not me but the sender is what the user inputs in the mail box and I receive the email FROM the input value rather than myself
From comments:
This is the solution:
set mail.From = new MailAddress(address, display name)
in Gmail, go to Mail Settings >> Accounts and Import.
Add the email account you will use as sender in "Send Mail As". (tick
as Alias)
This is the only way gmail will let you specify the from address.
Setting the From Address requires special configuration/confirmation in Gmail for each From Address (see here), or is otherwise prohibited.
You could create a generic gmail address such as no-reply-yourapp#gmail.com. Then use the ReplyToList property to set the default Reply To email address that the user will use for their reply, to the user input email address, as well as an appropriate Display Name for the sender.
So in theory, for flexibilty use different mail service such as web host provided or outlook etc and set the mail.FROM to the value from the textbox and it will be sent from the address the user has typed? Gmail being extra secure causes confusion. Got it. Thanks guys

Display the recipient's name on an email sent via EWS

I wish to pragmatically send an email from an exchange mailbox but when viewed in sent items in outlook display the contact name rather than the email address (like it does when sending via outlook).
I have attached a one drive link with an image example below, of viewing a sent item in outlook, when sent from outlook. My pragmatically sent email needs to replicate this.
How do I send an email using EWS so that the recipients name, and not only his address is shown?
https://onedrive.live.com/redir?resid=8F8BF7DFDA3B485C!443361&authkey=!AOiPcHZJePBNmJk&v=3&ithint=photo%2cjpg
Thanks a bunch
Set the Name property for the EmailAddress you use as recipient.

Categories

Resources