How to post an activity as a reply in Bot Framework Slack channel? - botframework

How would one go about posting an activity as a reply in Slack instead of a new message in the channel?
I have tried setting the replyToId field and construct it like shown below, but the resulting message was still not posted as a reply.
// Create the reply
const replyActivity = MessageFactory.text(replyText, replyText);
// Post the reply as a reply to parent message
replyActivity.replyToId = context.activity.conversation.id
+ ':'
+ context.activity.channelData.SlackMessage.event.ts;
Tried appending the ID of the parent message to the conversation object and setting as the replyToId property but it didn't help.

Of course, after posting I realize to try the following and it works. Sharing here for everyone's benefit.
// Copy the conversation object from original message
replyActivity.conversation = context.activity.conversation;
// Append the ID of the parent message to post our message as reply
replyActivity.conversation.id += ":" + context.activity.channelData.SlackMessage.event.ts;

Related

Writing code stage to determine if recipients are from the domain

I need to write a piece of code in the Code Stage in Blue Prism. I am dealing with Outlook and my current object can send out emails in Outlook.
However, what I need to do now is to check if the email addresses in to/cc/bcc are from the same domain (eg. check if all recipients' email addresses end with "#abc.com"). My current piece of code is coded in C#. Does anyone have any idea on how this can be done?
Here is what I have currently:
I have a list of input parameters for fields like "to, from, cc, bcc, ..., abc_recipients_only". All the parameters are in string and the "abc_recipient_only" parameter is in a Boolean form.
The codes I have currently gives me an error saying "Compiler error at line 14: The name "Recipient" does not exist in the current context"".
EmailMessage email = new EmailMessage(service);
to = to.Replace(',',';');
cc = cc.Replace(',',';');
bcc = bcc.Replace(',',';');
foreach(var row in to.Split(';')){
if (abc_recipients_only == true){
if(Recipient.AddressEntry == "abc.com"){
email.ToRecipients.Add(row.Trim());
}
}
else{
if (string.IsNullOrEmpty(row.Trim())) continue;
email.ToRecipients.Add(row.Trim());
}
}
email.SendAndSaveCopy();
The MailItem.Recipients property returns a Recipients collection that represents all the recipients for the Outlook item. So, you can iterate over all items in the collection and check recipient's domains.
Use the Recipients (index) method, where index is the name or index number, to return a single Recipient object. The name can be a string that represents the display name, the alias, the full SMTP email address, or the mobile phone number of the recipient. A good practice is to use the SMTP email address for a mail message, and the mobile phone number for a mobile message.
The Recipient.Address property returns a string representing the email address of the Recipient.
If you meet an exchange-like email address you can use the approach described in the HowTo: Convert Exchange-based email address into SMTP email address article.
Assuming your company is using Exchange, loop through all recipients in the message (MailItem.Recipients collection) and check if each address type is "EX" - Recipient.AddressEntry.Type == "EX" or Recipient.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3002001F") == "EX". The latter is more efficient.

Discord.js #everyone / #here issues with message

I have the code here for my embed announce feature, if a role is mentioned then it sends that role mention to the channel and then sends the rest of the message in an embed, i also have a variation for user mentions. How do i adapt this to do the same for #everyone & #here? they dont have ID's like roles. Either that or i cant find the ID of #everyone & #here. typing #everyone results in #everyone being returned, not an ID
if (args[1].startsWith('<#&') && args[1].endsWith('>')) {
message.channel.send(args[1])
const embed = new Discord.MessageEmbed()
.setTitle(`${(args.slice(2).join(" "))}`)
.setColor(0x320b52)
.setTimestamp()
.setFooter('Requested by ' + message.author.tag)
message.channel.send(embed);
Correct, #everyone and #here do not have IDs. Simply check whether either of them matches args[1].

How to set sender name in message sent using outlook 2010/13 ? <MAPI>

I've been fetching value of the user name from user's profile "PR_DISPLAY_NAME" and set the same value as sender in "PR_SENDER_NAME_X" property value. But it seems outlook 2010\13 always sets the user name as email address at the time of profile creation. Even if we add the user name manually, it is replaced by the email address when outlook profile/account is created.
My questions are - How do I get the actual user's name so that I can set the same as sender name ? How does transport provider set the sender name which is displayed in From field ( "PR_SENDER_NAME_X" property value) when an email is sent?
I tried searching any relevant property but couldn't find.
I am connected to exchange server 2k10 through outlook MAPI account.
At this moment I see following possibilities to get the sender name but I don't think these are the right way to fix the problem.
There is profile property PR_PROFILE_USER which consists a DN name. We can
extract the user name from this property.
we have the email address, query that in the address book and get the user
name from there. But I not sure if address book always keeps the current user
After rounds of discussions with Dmitry. I was able to solve my problem as following -
I already had LeagcyDN or exchange name of the user, so from that I created the EntryId of Sender.
Get the IAddrBook* from IMAPSupport as following -
lpMAPIsupport->OpenAddressBook(NULL, 0, &lpAddrBook);
Get the MAPI properties of sender from the Addressbook pointer of the user.
Get the PR_DISPLAY property of the sender from MAPI properties.
Perhaps following code will help to understand
hrRet = lpMAPIsupport->OpenAddressBook(NULL, 0, &lpAddrBook);
if (SUCCEEDED(hrRet) && lpAddrBook != NULL )
{
hrRet = lpAddrBook->OpenEntry(cbEntryID, lpEntryID, &IID_IMAPIProp, 0, &ulEntryType,
(LPUNKNOWN *)&lpMapiProp);
if (SUCCEEDED(hrRet) && lpMapiProp != NULL )
{
HrGetOneProp(lpMapiProp, PR_DISPLAY_NAME_W, true, UserName);
}
}
Note - If you don't have LegacyDN then you can extract that from PR_STORE_ENTRYID property of the message.
Thanks Dmitry.

Is there an easy to use form to email with attachment for joomla?

I'm trying to build a custom form for a joomla website that allows users to complete some fields and attach a document that will be sent to an email address I can specify.
Does anyone know of any good components or plugins for accomplishing this ?
$from: This is the the email address that the email will look like it is coming from.
$fromname: This is the name of the person or organization this email is coming from.
$recipient: This is the email address (or array of email addresses) that the email will be going to.
$subject: This is the Subject of the email.
$body: The is the message body of the email.
$mode: Set this to 1 for HTML email, set it to 0 for text email. This field is optional.
$cc: This is the email address (or array of email addresses) that the email will be Carbon Copied to. This field is optional.
$bcc: This is the email address (or array of email addresses) that the email will be Blind Carbon Copied to. This field is optional.
$attachment: This is the full path and filename (or array of full paths and filenames) of the files that you wish to attach to the email. This field is optional.
$replyto: This is the the email address that the email will go to if the recipient clicks reply. This field is optional.
$replytoname: This is the name of the person or organization this email will go to if the recipient clicks reply. This field is optional.
Now that you know how that works, let's look at an example!
$from = 'admin#somewhere.com';
$fromname = 'BIGSHOT Blog';
$recipient[] = 'john#somewhere.com';
$recipient[] = 'jane#somewhere.com';
$subject = 'Want to learn about BIGSHOT Blog';
$body = '<p>Check us out!</p><p>http://www.somewhere.com</p>';
$mode = 1;
$cc = 'bob#somewhereelse.com';
$bcc[] = 'simon#somewhereelse.com';
$bcc[] = 'nick#somewhereelse.com';
$attachment[] = '/home/my_site/public_html/images/stories/food/coffee.jpg';
$attachment[] = '/home/my_site/public_html/images/stories/food/milk.jpg';
$replyto = 'no_reply#somewhere.com';
$replytoname = 'NO REPLY - BIGSHOT Blog';
JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname);
You can use JUtility::sendMail to send an email in Joomla with attachment.For more information how to use go to this link.
JUtility/sendMail
A little more digging on the joomla extensions directory and I think I found what I need: http://extensions.joomla.org/extensions/contacts-and-feedback/contact-forms/11494

EWS-managed: Fetch required and optional attendees of appointments

As far as I am now, I know how to fetch appointments from exchange server, BUT as soon as I want to see the required and optional attendees, these fields are empty ... I checked the appointment trice and there is an attendee, except me. Do I have to config Outlook differently or do I miss something?
List<Appointment> listOfAppointments = new List<Appointment>();
CalendarFolder cfolder = CalendarFolder.Bind(MyService, WellKnownFolderName.Calendar);
CalendarView cview = new CalendarView(from.ToUniversalTime(), to.ToUniversalTime());
cview.PropertySet = new PropertySet(ItemSchema.Subject);
cview.PropertySet.Add(AppointmentSchema.Start);
cview.PropertySet.Add(AppointmentSchema.End);
cview.PropertySet.Add(AppointmentSchema.Location);
cview.PropertySet.Add(AppointmentSchema.ICalUid);
cview.PropertySet.Add(AppointmentSchema.Organizer);
cview.PropertySet.Add(AppointmentSchema.IsAllDayEvent);
cview.PropertySet.Add(AppointmentSchema.DateTimeCreated);
FindItemsResults<Appointment> result = cfolder.FindAppointments(cview);
thats how I fetch the appointments, as I figured from exceptions and trail and error, I don't need to ask exchange for attendees... but maybe I am missing something.
The FindAppointments operation do not return the attendees of meetings. Instead, specify a propertyset of PropertySet.IdOnly to get only the ids of the items. Then, use the ExchangeService.LoadPropertiesForItems to perform a batch load of the properties you need.

Resources