How to send a simple adaptive card via email? - outlook

I've taken a look at the documentation for adaptive cards and actionable messages. I want to send an adaptive card via email and view it in outlook.
https://learn.microsoft.com/en-us/outlook/actionable-messages/actionable-messages-via-email
I am able to use the card playground (https://messagecardplayground.azurewebsites.net/) to send an email to myself with an adaptive card (using the button in the top right), and it renders correctly.
Everything I read about these adaptive cards makes it sound like you can just send the html markup via email (see first link). However, when I try sending the example html from that page (either with all the html tags, or just with the script tag), an adaptive card is not created, and the adaptive card debugger add-in doesn't notice anything either.
How can I send an adaptive card via email myself?

Still not sure if I would be able to do this through an Outlook client (or any other mail client), but I was able to do it using a simple C# program that sends an email through Outlook's SMTP server.
MailMessage mail = new MailMessage("outlookemail#domain.com", "outlookemail#domain.com");
SmtpClient client = new SmtpClient();
string Body = System.IO.File.ReadAllText(#"C:\fullpathhere\test.html");
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Host = "smtp-mail.outlook.com";
client.EnableSsl = true;
client.Timeout = 10000;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("outlookemail#domain.com", "password");
mail.IsBodyHtml = true;
mail.Subject = "Actionable Message Test Email";
mail.Body = Body;
client.Send(mail);
The test.html file is just the full HTML from the bottom of https://learn.microsoft.com/en-us/outlook/actionable-messages/message-card-reference.
Keep in mind most Outlook clients can't render adaptive cards and can only use actionable messages. Outlook 365's online client can render them though.

Related

how to send an email from a microsoft bot?

I developed a chatbot and deployed it on skype. I have one new thing to be added to bot.
If a user requests for a office cab in bot then bot has to take user input(like destination, emp-name, etc) and send an email to a particular mail ID(outlook).
So my question is:
How to trigger an email from Bot?
You can use SendGrid.
Here with example code.
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.sendgrid.net");
mail.From = new MailAddress("youremailaddress#gmail.com");
mail.To.Add(useremail);
mail.Subject = "";
mail.Body ="";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("apikey", "");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
References: How to make my bot send an e-mail to a given email address?
Try to use Email Skill from Bot Framework:
https://microsoft.github.io/botframework-solutions/skills/samples/email/

HTML email is getting displayed as plain/text with javamail in Gmail and Yahoo

Trying to send HTML email with java-mail . I can see HTML format email in Outlook but Gmail and Yahoo don't show HTML format , they are showing email as plain texts without HTML formatting .
I am using company's SMTP server to send an email to users .
I tried following and msgcontent is StringBuilder in following code :
Properties prop = System.getProperties();
prop.put("mail.smtp.auth", "false");
prop.put("mail.smtp.starttls.enable","false");
prop.put("mail.smtp.host", SMTP_SERVER);
Session session = Session.getInstance(prop);
MimeMessage msg = new MimeMessage(session);
MimeMultipart multipart = new MimeMultipart();
MimeBodyPart content = new MimeBodyPart();
content.setHeader("content-type", "text/html");
msg.setFrom(new InternetAddress(EMAIL_FROM));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(EMAIL_TO, false));
msg.setSubject(EMAIL_SUBJECT);
content.setContent(msgcontent.toString(), "text/html");
multipart.addBodyPart(content);
msg.setContent(multipart);
I want HTML email to be displayed in all email clients like Gmail , Yahoo, etc. Currently only Outlook can display HTML content.
You don't really need a multipart since your message has only one part.
You can simplify the content setting by replacing the two content.set* lines with:
content.setText(msgcontent.toString(), "utf-8", "html");
What version of JavaMail are you using?
If you examine the raw MIME content of the message you receive and compare it with the raw MIME content of the message you send, are they different?

MS Teams - Don't show notification of specific message in the activity feed

Question
I have a simple Bot for MS Teams developed in C# with the Bot Builder SDK 3.15.0.0 targeting .NET framework 4.7.1.
When mentioned, it retrieves the Jira ticket Ids in the message and returns a single reply with a list of Cards, each one displaying a summary of a Jira Issue.
I'd like to know if it's possible to not populate the activity feed when sending the reply with the card attachments as it's not needed for my use case.
Example
This is how I usually build the reply to a user message
var reply = activity.CreateReply();
reply.AttachmentLayout = AttachmentLayoutTypes.List;
reply.Attachments = thumbnailCards;
await context.PostAsync(reply);
And this is what I tried after reading the docs at https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/activity-feed#rest-api-sample
var reply = activity.CreateReply();
reply.AttachmentLayout = AttachmentLayoutTypes.List;
reply.Attachments = thumbnailCards;
reply.ChannelData = JsonConvert.SerializeObject(new
{
notification = new
{
alert = false
}
});
await context.PostAsync(reply);
I was hoping that setting the ChannelData with notification.alert = false would just disable the notifications, but it actually doesn't display any message.
Have you tried using the Teams nuget package: https://www.nuget.org/packages/Microsoft.Bot.Connector.Teams
var reply = activity.CreateReply();
reply.ChannelData = JObject.FromObject(new TeamsChannelData()
{
Notification = new NotificationInfo(false)
});
Source for this package can be found here: https://github.com/OfficeDev/BotBuilder-MicrosoftTeams/
The alert you are getting in the activity feed is simply the "someone replied to your message" alert and is nothing special coming from the bot. This notification in the activity feed cannot be disabled as of now. Other team members won't receive this alert in activity feed unless they are following the same channel.
Sending notification using Rest API is designed to work for 1:1 chat.

Create mail in Exchange Online inbox programatically

Have been facing an issue since days about EWS. So my scenario is;
I was to programmatically sync GMAIL and EXCHANGE ONLINE. So here is what I have done;
Connect to Gmail using Gmail API
Fetch mail from gmail get the email body, to, from, attachment and
all other thing
connect to Exchange online using EWS 2.0
Now the problem is here, how can I create an email in Inbox which looks like incoming mail from the sender;
Here is the code I have done;
_service = new ExchangeService(ExchangeVersion.Exchange2013);
_service.TraceEnabled = true;
_service.Credentials = new WebCredentials("admin#xyz.onmicrosoft.com", "password");
_service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
_service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "xyz#xyz.onmicrosoft.com");
EmailMessage message = new EmailMessage(_service);
Random r = new Random();
message.Subject = "Email Message";
message.From = new EmailAddress("xyz#gmail.com");
message.Sender = new EmailAddress("xyz#gmail.com");
message.Body = new MessageBody(BodyType.HTML, "<HTML><body><h1>This is a voice mail.</h1></BODY></HTML>");
message.ToRecipients.Add(new EmailAddress(""));
message.Save(WellKnownFolderName.Inbox);
This way its creating an email in inbox but it shows as a draft mail. I dont want it, I want it to look as RECEIVED mail.
Am I doing anything wrong?
You need to set a couple of properties before saving the message.
// Set a delivery time
ExtendedPropertyDefinition PidTagMessageDeliveryTime =
new ExtendedPropertyDefinition(0x0E06, MapiPropertyType.SystemTime);
DateTime deliveryTime = DateTime.Now; // Or whatever deliver time you want
message.SetExtendedProperty(PidTagMessageDeliveryTime, deliveryTime);
// Indicate that this email is not a draft. Otherwise, the email will appear as a
// draft to clients.
ExtendedPropertyDefinition PR_MESSAGE_FLAGS_msgflag_read = new ExtendedPropertyDefinition(3591, MapiPropertyType.Integer);
message.SetExtendedProperty(PR_MESSAGE_FLAGS_msgflag_read, 1);
These properties aren't settable after the items is saved, so it's important to do it before the first Save call.

How to get SMTPHost in custom workflow activity in MS Dynamics CRM?

I am trying to send email in custom workflow activity using SMTPClient instead of using Email entity and SendEmailRequest in MS Dynamics CRM custom workflow activity.
The reason I am doing this is because I want to send an calendar meeting invitation to the customer and not the email. For basics I got the code below:
MailMessage mail = new MailMessage("you#yourcompany.com", "user#hotmail.com");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.google.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
I intend to use DDay.iCal for the purpose.
Now this might seem to be a very basic question but I am stuck in how to get the Host name value in the custom workflow activity (instead of smtp.google.com).
Please advise.
Thanks,
I figured it out. It was in my email router configuration in "Email Server" column.

Resources