Trigger ItemSend when item is being sent from outbox using addon - c#

I'm writing an outlook addon that triggers when the Send button is sent on an email, if certain conditions are met a pop up comes up asking if the user is sure they want to send the email.
This works perfectly. However, A lot of emails that get sent are passed into outlook through another program and go into the drafts folder and are slowly sent out. Is there an Event handler for when an email is sent that doesn't rely on the send button being clicked?
EDIT:
I've found that the Send() method can be called to send an email - would it be possible to check if this method is called and when it is to run my code?

If the external app is using the Outlook Object Model to send the messages, Application.ItemSend event will still fire. Otherwise the best you can of is use Items.ItemAdd event on the Sent Items folder - it will trigger after a message is actually sent and moved to the Sent Items folder.

Related

Proactive messaging with prompt buttons - Microsoft Bot Framework

I've been playing around with proactive messaging, but I'm not sure how to achieve something like this. I've got a service that messages users products on a daily basis. Using a resumption cookie I call an end point, build a response by setting the .Text property and create the carousel of products by populating the .Attachments property. I want to add buttons to this message to allow a user to stop the alerts, but the only event a CardAction button allows is opening an URL in a web browser. Is there a way of creating a button which can trigger a method, or call a new dialog?
Any help will be greatly appreciated.
You can just use the ImBack or PostBack ActionTypes on the CardAction. Clicking on a button when using any of those, will send a message to the conversation with the Value of the action that will end up arriving to the method you are "waiting" (by doing context.Wait(...));
Then, in that method you can do whatever you want: call a new dialog or any other logic you want to trigger.
In the ContosoFlowers sample you can see how a card with buttons is used in that way.

Programatically create & send outlook email WITH a visual email popping up on screen

I want to be emailing with a Outlook add-in, I've followed as a previous user did:
Trying to Programmatically Create & Open a new Outlook Email
To create said email, but What if anything can I do to make it so outlook doesn't have this email pop-up on screen, and just sends it.
MailItem doesnt seem to have any kind of .Visible attribute that I'm aware of.
Is there a way to "hide" the Email? My add-in is set to a timer so it's sort of annoying for my system to pop up an email window on me every 30 minutes :/
Well, if you don't want to display the email, don't call Display. Call Send instead.

Handling attachment events in an outlook add-in

Is anyone aware of a technique I could use to override someone opening an email attachment within an outlook add-in?
Essentially what I'm being asked to do, is for certain attachments, to change the behavior so instead of opening the attachment the user is redirected to a webpage.
I can hook into the attachment context menu with Application.AttachmentContextMenuDisplay however that is not fired if the user simply double clicks on an email attachment.
Environment used is VS2010, c#, and outlook 2007/2010.
You should take a look at the ItemEvent BeforeAttachmentRead and BeforeAttachmentPreview. See this related post for reference.
((Outlook.ItemEvents_10_Event)MailItem).BeforeAttachmentRead += new Outlook.ItemEvents_10_BeforeAttachmentReadEventHandler(ItemEvents_BeforeAttachmentRead);
((Outlook.ItemEvents_10_Event)MailItem).BeforeAttachmentPreview += new Outlook.ItemEvents_10_BeforeAttachmentPreviewEventHandler(ItemEvents_BeforeAttachmentPreview);

user replying to email messages. How can you get data from users email?

I have difficulties implementing the following scenario.
Let's say you have a web site with ability to send and recieve messages between users.
User recieves an email with notification he has a new message on the software system (doesn't matter in what it is implemented). He can respond to this message by sending a reply via email or by logging into the site and replying to the 'message' using the site.
In case of the first approach if user simply replies to the email notification, how can you (as a developer) know what 'message' (ID) is the reply for?
I'm thinking the info would be stored in the MIME extensions. Are the MIME extensions transfered to the reply of the message? If yes than the solution could be to see the data of the original message notification for wich the user replyes to.
Any ideas? Thank you
The only “reliable” way would be to encode that information in the sender's address to which the user replies; you could also put it into subject or body of the message, and “hope” that the user doesn't tamper with it. There is an “in reply to (message-id)” header, but a lot of existing eMail clients don't set the header properly.
The usual mechanism is something like this: create an eMail alias prefix, and the append a message-id-code fragment to the end; for example, if this was for a purchase order confirmation, you could create an eMail alias handling addresses of the form po-*#example.com, where * is the unique message ID. Then, when you send your message out, you'd put the appropriate address in both the From: and Reply To: headers. EG:
From: "Purchase Order Confirmation (#1234)" <po-1234#example.com>
To: "John Doe" <jdoe#example.com>
Reply-To: "Purchase Order Confirmation (#1234)" <po-1234#example.com>
Subject: Confirm your order (#1234)
Depending upon your mail server, you should be able to define a “separator” character (typically - or +) that is used to split up the parts of the “local part” (left of #) of the eMail address; there is typically then another mechanism to map a prefix to a script to handle all addresses of a certain form. The script interface is often very much like CGI on the web, sending in some environment variables and piping the message itself in on the standard input. If your app is primarily web-based, you might find it more “comfortable” to gather the incoming eMail body, and POST it to a private (perhaps http://[::1]/getMailReply) handler. This may help you reuse existing code more readily.
We have set up a catch-all email address on our server - for example catch-all#myserver.com. When we send emails to users, we encode the message id and any other meta information we may need in the from address. You can obfuscate this or not, depending on what your needs are. So, for example, if the user has a new message in the system whose ID is 100, the from address of the email we send to the user would be something like reply-to-message-100#myserver.com. Make sure that whatever format you use for the from address would never generate a real email address on your mail server.
So, when the user responds to this message, it will get sent to the catch-all inbox you have set up. From here, you have a number of choices to make on how you process this email. In times past, we wrote a little scheduled service that would run every few minutes and check this inbox for new emails, process them as you like (insert into db, send more emails, whatever), and delete the message since you're done processing it. This is fragile since email clients all have slightly different ways of sending emails and it becomes difficult to parse the variety of client messages out there.
The second way we've done it is by integrating with http://postmarkapp.com/ - which has an incoming email api that should go public soon (we got in on the beta). You'd set everything up the same way only make your server's catch-all address forward to the postmark incoming address you'll set up with Postmark, and then Postmark does the message processing and calls a webhook you also set up to do what you like with the object received.
I highly recommend Postmark, but even the homespun method worked effectively, for the most part.
-M
Just a followup to the previous answer, Postmark Inbound is now live and public http://postmarkapp.com/inbound For each email sent to your specially formatted inbound email address, you'll receive a JSON formatted web hook API call with all the email components, headers, attachments sorted for you.

How to know if the other user is now writing a message in web chat website?

I am building a chat system in an ASP.Net MVC website, and I want the user see if the other chat user is now writing a message.
The same as it appear in gtalk or msn, when the other user start writing it says: "userA is writing ...." then it hide this message when the user stops.
What will be the concept behind this feature to implement on a website, and what I should know to build it the right way?
This is all done via AJAX
User1 sends a writing=true value to the server as soon as writing begins, and writing=false when message is submitted.
User2 polls the server every x seconds to see if(writing){display "User1 is writing a message"}
This is obviously two way, so User1 and User2 are both pushing and pulling the writing boolean from the server.
I'd suggest using jQuery and JSON for this process.
Look for an "on change" (or equivalent) for your edit text. Start a timer when it happens and send an ajax message to the chat server(s) to notify them. When the text is submitted or the timer runs out, clear the message.
Client-side, have a timer count to 500ms and a variable sentState set to false.
Whenever the client types something, reset that timer, the, if sentState is, send an AJAX request to the server indicating that the client is typing. Finally, set sentState to true.
If the timer reaches 500ms, send an AJAX request to the server indicating that the client is no longer typing and set sentState to false.

Categories

Resources