When I send a mail with the option "Encrypt only" in Outlook
I receive a mail like this :
Currently, I use SMTPClient with MailMessage to send mail :
MailMessage message = new MailMessage();
message.From = from;
MailAddress to = new MailAddress(destString);
message.To.Add(to);
message.Subject = subject;
smtpClient.Send(message);
How can I modify my code to send a mail and receive it as the mail above ?
After some researching, I found a solution by using Interop but I can't use it in my project.
var app = new Microsoft.Office.Interop.Outlook.Application();
var item = (Microsoft.Office.Interop.Outlook.MailItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
item.To = abc#gmail.com;
item.Subject = "test";
item.Permission = Microsoft.Office.Interop.Outlook.OlPermission.olDoNotForward;
item.PermissionService = Microsoft.Office.Interop.Outlook.OlPermissionService.olWindows;
item.Send();
As far as I understand Outlook puts the message in a secure server (Office 365 in my case) and sends the recipient a link to open that message.
It is stated in this url, this feature is only for some licenses.
Microsoft 365 Message Encryption is part of the Office 365 Enterprise E3 license. Additionally, the Encrypt-Only feature (the option under the Encrypt button) is only enabled for subscribers (Microsoft 365 Apps for enterprise users) that also use Exchange Online.
I cannot find an API or library documentation, but you should try to communicate with your MS representative about this, so they can provide more information.
Related
I am trying to use MailKit for sending email via office 365 for a web app that I am currently developing.
I have had various issues in the past with office 365 and sending emails and this evening I have stumbled across multiple articles and stack questions addressing office 365 and sending via smtp and MailKit being the preferred option.
I am using this code
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Simon Price", "simon.price#xxxx.co.uk"));
message.To.Add(new MailboxAddress("Recipient Nasme", "emailAddress"));
message.Subject = "Still hitting spam";
message.Body = new TextPart("html")
{
Text = #"sample test"
};
using (var client = new SmtpClient())
{
client.Connect("smtp.office365.com", 587, SecureSocketOptions.Auto);
// Note: only needed if the SMTP server requires authentication
client.Authenticate("simon.price#sxxx.co.uk", "xxxx");
client.Send(message);
client.Disconnect(true);
}
Which does send the email, however, it continually hits the spam folders of each recipient. I very much suspect this is me missing a configuration, however I cannot see where I am going wrong in this and would appreciate some help.
Resources I have looked at include but not exhausted (i may have missed some)
https://github.com/jstedfast/MailKit
https://dotnetcoretutorials.com/2017/11/02/using-mailkit-send-receive-email-asp-net-core/
Does Office 365 have a preferred way of sending attachments when using MailKit?
Authenticating to Office 365 Outlook IMAP using MailKit fails for a specific user
https://unop.uk/sending-email-in-.net-core-with-office-365-and-mailkit/
I have configured my application in Azure web apps. I am sending the mail using smtp server. The outlook is sending emails properly. Other mail providers like(Gmail) are not sending emails. Please help.
Other mail providers like(Gmail) are not sending emails
You could check the providers that have policy to allow to do that.
Take gmail for example, as Ankit Kumar mentioned that you need to turn Allow less secure apps: on for your gmail account.
I also test it on my side, it works correctly. The following is my demo code.
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Tom Gmail", "xx#gmail.com"));
message.To.Add(new MailboxAddress("Tom Hotmail", "xxx#hotmail.com"));
message.Subject = "I am a mail subject";
message.Body = new TextPart("plain")
{
Text = "I am a mail body."
};
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 587);
// Note: since we don't have an OAuth2 token, disable
// the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2");
// Note: only needed if the SMTP server requires authentication
client.Authenticate("sunguiguan#gmail.com", "#WSX3edc");
client.Send(message);
client.Disconnect(true);
}
We also could use SendGrid on the Azure,more detail please refer to How to Send Email Using SendGrid with Azure.
I am developing an ASP.NET website using Visual studio 2010 ultimate. I want to send mail for confirmation to the clients using my yahoo mail account. How can I do so ? what settings should I change or add ?
Here is the Yahoo mail settings
Yahoo! Mail SMTP server address: smtp.mail.yahoo.com
Yahoo! Mail SMTP user name: Your full Yahoo! Mail email address
(including "#yahoo.com")
Yahoo! Mail SMTP password: Your Yahoo! Mail password
Yahoo! Mail SMTP port: 465
Yahoo! Mail SMTP TLS/SSL required: yes
Here is a sample code to send email using yahoo mail settings
SmtpClient emailClient = new SmtpClient("smtp.mail.yahoo.com");
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("xyz#yahoo.com","*******");
emailClient.EnableSsl = true;
emailClient.Credentials = SMTPUserInfo;
emailClient.Port = 465;
MailMessage message = new System.Net.Mail.MailMessage("xyz#gmail.com", "someone#something.something", "fire!!", "Call up 911 and inform my house is on fire and my phone too");
emailClient.Send(message);
You need to have smtp/pop access to yahoo mail in order to send the mail using yahoo account. The free account offered by yahoo does not have that access. You might have to opt for yahoo mail pro.
For sending a mail using SMTP, all you need is username and password of an smtp account. You will use the pass this credentials and send the mail with classes system.net.mail namespace.
You can check this project:
http://www.codeproject.com/Articles/1684/Sending-Mail-Using-C-via-SMTP
There you will see how to setup configuration to send a mail using any (in your case yahoo) smtp server to send an email.
I have a C# program that I will be running on a daily basis (through Windows Scheduler). The program is to send a daily report to my team.
I have written the following to send the email and it works. the only problem is that Outlook shows a message box " A program is trying to send an e-mail message on your behalf. if this is unexpected...... " . there are three buttons "allow" "deny" "help" and it seems like my program is halted at that point and until i click the allow or deny button , the program doesn't send the email.
I know that the i can change the options by going into tools -> trust center -> programmatic access, but i would really like to not use that because this program would be eventually running from another machine where the user may or may not access to change the setting in trust center.
Is there a way to disable this warning programatically? ..or is there another way to send the email without having this warning popup
here is the code used to send the email..and it works fine..
Application olook = new Application();
NameSpace ns = olook.GetNamespace("MAPI");
ns.Logon(null, null, true, true);
_MailItem msg = (_MailItem)olook.CreateItem(OlItemType.olMailItem);
msg.To = "xxx#xxx.com";
msg.Subject = "test";
msg.HTMLBody = strHTML;
msg.Send();
ns.Logoff();
there are several ways to do that
you could disable the popup like #DJ KRAZE described
or you could send a message via smtp, if thats possible in your environment
see this: http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx
then you could use the "redemption library" i've used it and there will be no messages, because redemption suppresses them (or works around them) but the library is used via com, thats not that comfortable..
although you have to pay for that:
http://www.dimastr.com/redemption/home.htm
the thir alternative is using the managed Exchange Web Services
http://www.microsoft.com/download/en/details.aspx?id=13480
this is pretty straight forward and fun to use. you can get that via NuGet as well. :)
EDIT:
i forgot to mention, that Exchange Web Services are only available on Exchange 2007 SP1 or higher.
and this is what it looks like to send a message (after connect to the server)
EmailMessage message = new EmailMessage(service);
message.Subject = "Hello from the EWS Managed API";
message.Body = "Now that's easy!";
message.ToRecipients.Add("someone#fabrikam.com");
message.Save();
look here for an introduction: http://msdn.microsoft.com/en-us/library/dd637749(v=exchg.80).aspx
One of the easiest solutions is to use Exchange's SMTP server. Here's an example from MSDN.
string to = "jane#contoso.com";
string from = "ben#contoso.com";
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the new SMTP client.";
message.Body = #"Using this new feature, you can send an e-mail message from an application very easily.";
SmtpClient client = new SmtpClient(server);
// Credentials are necessary if the server requires the client
// to authenticate before it will send e-mail on the client's behalf.
client.UseDefaultCredentials = true;
client.Send(message);
Of course, you'll have to check with your Exchange administrator to make sure that SMTP is enabled.
I am trying to write code to send a simple mail from asp.net page.
Confusion is over what to write under "smtp server", when I want to send mail using Microsoft Outlook 2007.
Two sets of code I'm trying:-
1.)
MailMessage objMail = new MailMessage();
objMail.From = "angenlina.jolie#compnayabc.com";
objMail.To = "brad.pitt#companyabc.com";
objMail.BodyFormat = MailFormat.Text;
objMail.Priority = MailPriority.High;
objMail.Subject = "Hi Sweetheart";
string smtpadd = "USA-LA-MAIL1.corp.hollwood.com";
SmtpMail.SmtpServer = "smtpadd";
SmtpMail.Send(objMail);
2.)
SmtpClient smtp = new SmtpClient();
smtp.Port = 25;
smtp.Host = "USA-LA-MAIL1.corp.hollwood.com";
smtp.Credentials = new NetworkCredential("username", "password");
MailMessage email_msg = new MailMessage();
email_msg.To.Add("brad.pitt#companyabc.com");
email_msg.From = new MailAddress("angenlina.jolie#companyabc.com");
email_msg.Subject = "test mail...";
email_msg.Body = "Hi SweetHeart";
email_msg.IsBodyHtml = false;
smtp.Send(email_msg);
Now my problem is what server name should I use for Microsoft outlook 2007(MS exchange server)?
Now my problem is what server name should I use for Micrsoft outlook 2007(MS exchange server)?
Are you sending email via MAPI (using their "Outlook profile") or via SMTP through an Exchange Server? They're not the same.
If you are sending through Exchange then the server will need to be configured to relay mail via SMTP. In which case, put the Exchange server in as the SMTP server.
If you're sending email via MAPI then you'll be using whatever mail server is configured in their "Outlook profile". Which could be SMTP, IMAP, Webmail (with a Hotmail connector or Gmail connector) or Exchange Server.
EDIT:
It sounds like you want to use the Exchange server via MAPI. Here is a good primer to the technologies involved.
Bear in mind that if you're configuring MAPI profiles from within the ASP .NET application you're going to pay attention to the service account the ASP .NET application runs as and that the MAPI is sometimes interactive and not suitable for service based applications.
You may be better off having an administrator configure the Exchange server to route email via SMTP (which is most likely is, unless you have a spam appliance in front of the server which handles SMTP).
try something generic i.e
Email Client setup information
IMAP server: imap.smtpserver.in
POP server: pop.smtpserver.in
SMTP server: smtp.smtpserver.in
Webmail
To access your email through a web browser visit http://webmail.smtpserver.in
smtpserver.in is your smtpserver host address.