none
auto responder based on body content RRS feed

  • Question

  • I was perusing the following topic which appears to question what we similarly need to accomplish:

    http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/5a8322cd-9093-48b1-ae2b-a533104bf95f

    Essentially we have a client that receives referral notifications and wants to personalize the message based on the body content which will always come from several email sources.  Here is yet another example:

    From: sponsorleads@JMB.com
    Sent: Wednesday, May 01, 2013 9:57 AM
    To: Michael Attorney
    Subject: New Lead from JMB: Doe, John

    First Name: John
    Last Name: Doe
    Email: John.Doe@outlook.com

    We want the auto-reply email to go to John.Doe@outlook.com and include the first and last name in a personalized reply which may also include a few embedded images as well.

    While I see in link I provided it suggested to use a VSTO add-in, I was also wondering if this needs to be on the client's exchange server or on his Outlook.  Please advise.

    Friday, May 31, 2013 3:14 PM

All replies

  • Outlook addins run in Outlook and are installed in Outlook. Outlook must be running for them to run. That applies to shared COM addins as well as to VSTO addins.
     
    Exchange server side code would run these days using EWS (Exchange Web Services) code and you need permissions from the Exchange admins to run it and for them to turn on EWS. FWIW, many Exchange admins don't like code to run at the server or on folders at the server as bad code can hang or otherwise mess up the entire Exchange server.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "jfalberg" <=?utf-8?B?amZhbGJlcmc=?=> wrote in message news:edcdf974-04d8-4c84-af24-83f83312ab40...

    I was perusing the following topic which appears to question what we similarly need to accomplish:

    http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/5a8322cd-9093-48b1-ae2b-a533104bf95f

    Essentially we have a client that receives referral notifications and wants to personalize the message based on the body content which will always come from several email sources.  Here is yet another example:

    From: sponsorleads@JMB.com
    Sent: Wednesday, May 01, 2013 9:57 AM
    To: Michael Attorney
    Subject: New Lead from JMB: Doe, John

    First Name: John
    Last Name: Doe
    Email: John.Doe@outlook.com

    We want the auto-reply email to go to John.Doe@outlook.com and include the first and last name in a personalized reply which may also include a few embedded images as well.

    While I see in link I provided it suggested to use a VSTO add-in, I was also wondering if this needs to be on the client's exchange server or on his Outlook.  Please advise.


    Ken Slovak MVP - Outlook
    Friday, May 31, 2013 7:30 PM
    Moderator
  • It looks like my alternative is to create a c# add-in onto a dedicated workstation that has outlook opened at all times.  I notice in the following line of coding:

    string restrictCriteria = "[UnRead] = true"
    resultItems = folderItems.Restrict(restrictCriteria); 

    I tried using one of the view filter methods (url:schema) but it didn't seem to like that so I was 
    wondering if there was a list if I wanted to change the restrictcriteria to "[To]='john.doe@outlook.com'" using my test examples
    restored to my inbox for testing 
    purposes, or once I'm finished with my loop to either mark as read or move to a separate folder.





    • Edited by jfalberg Monday, June 3, 2013 11:28 PM
    Monday, June 3, 2013 11:25 PM
  • Using the text fields To, Cc and Bcc often doesn't provide the results you might expect. The same recipient can be in those fields in a number of different formats depending on whether the recipient is a contact, in a GAL, Outlook version, etc.
     
    So you might see 'john.doe@outlook.com' or 'John Doe' or '<John Doe> john.doe@outlook.com' or various other forms. You can also have more than 1 To recipient, in which case the restriction you propose would also fail.
     
    If anything I'd use a LIKE operator rather than '=' in the filter with the filter starting with "@SQL=" and using DASL property tags such as "http://schemas.microsoft.com/mapi/proptag/0x0E04001F" for To.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "jfalberg" <=?utf-8?B?amZhbGJlcmc=?=> wrote in message news:deb5bca1-ccd3-4f33-b9bf-f086d5df0a85...

    It looks like my alternative is to create a c# add-in onto a dedicated workstation that has outlook opened at all times.  I notice in the following line of coding:

    string restrictCriteria = "[UnRead] = true"
    resultItems = folderItems.Restrict(restrictCriteria); 

    I tried using one of the view filter methods (url:schema) but it didn't seem to like that so I was 
    wondering if there was a list if I wanted to change the restrictcriteria to "[To]='john.doe@outlook.com'" using my test examples
    restored to my inbox for testing 
    purposes, or once I'm finished with my loop to either mark as read or move to a separate folder.






    Ken Slovak MVP - Outlook
    Tuesday, June 4, 2013 2:32 PM
    Moderator
  • The DASL property method seemed to work nicely, now hopefully I can either mark as read or move incoming message to a separate folder once considered done so it doesn't get repeated next time an incoming message comes through.
    Tuesday, June 4, 2013 3:10 PM
  • While I may be restricting on unread=true:

    string restext = "@SQL=urn:schemas:httpmail:read=0";

    Is there any way or perhaps a specific schema which would indicate to me which is the newest email that arrived and triggered my add-in function to execute?

    ItemAdd somehow?



    • Edited by jfalberg Tuesday, June 4, 2013 7:28 PM
    Tuesday, June 4, 2013 6:46 PM
  • Sure. Sort the filtered Items collection returned by Restrict(). Use whatever date field that's most suitable for what you want.

    Ken Slovak MVP - Outlook

    Tuesday, June 4, 2013 7:53 PM
    Moderator
  • Hmmm, I notice that when I trigger the newmail event, it does not always get the new item that was added.  Here's my code so far:

           

    privatevoid ThisAddIn_Startup(object sender, System.EventArgs e)         {             read_inifiles(); // actually hardcoded valid email and subject text for now.             this.Application.NewMail += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_NewMailEventHandler(thisAddIn_NewMail);                      }         void thisAddIn_NewMail()         {                          Outlook.NameSpace outlookNameSpace = this.Application.GetNamespace("MAPI");             Outlook.MAPIFolder inbox = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);             Outlook.Items items = inbox.Items;             items.Sort("[Received]"true);             Outlook.Items ResItems = null;             string restext = "@SQL=urn:schemas:httpmail:read=0";             ResItems = items.Restrict(restext);                                       //MessageBox.Show(string.Format("Unread items in Inbox = {0}", ResItems.Count));foreach (Outlook.MailItem mail in ResItems)             {                 parse_NewMail(mail); // function where body gets parsed and then creates and sends a reply if succeeds.             }         }

    Should I be using the itemadd event instead? and I couldn't seem to find a good example as to how to correctly use it though.

                  


    Tuesday, June 4, 2013 8:17 PM
  • I'd probably recommend using NewMailEx() rather than either NewMail() or ItemAdd() on Inbox.Items. Both NewMail() and ItemAdd() can fail if 16 or more items are added in quick succession. NewMailEx() handles those cases better.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "jfalberg" <=?utf-8?B?amZhbGJlcmc=?=> wrote in message news:c0229363-bed4-4ac5-b1c5-a8b9122de26b...

    Hmmm, I notice that when I trigger the newmail event, it does not always get the new item that was added.  Here's my code so far:

           

    privatevoid ThisAddIn_Startup(object sender, System.EventArgs e)         {             read_inifiles(); // actually hardcoded valid email and subject text for now.             this.Application.NewMail += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_NewMailEventHandler(thisAddIn_NewMail);                      }         void thisAddIn_NewMail()         {                          Outlook.NameSpace outlookNameSpace = this.Application.GetNamespace("MAPI");             Outlook.MAPIFolder inbox = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);             Outlook.Items items = inbox.Items;             items.Sort("[Received]"true);             Outlook.Items ResItems = null;             string restext = "@SQL=urn:schemas:httpmail:read=0";             ResItems = items.Restrict(restext);                                       //MessageBox.Show(string.Format("Unread items in Inbox = {0}", ResItems.Count));foreach (Outlook.MailItem mail in ResItems)             {                 parse_NewMail(mail); // function where body gets parsed and then creates and sends a reply if succeeds.             }         }

    Should I be using the itemadd event instead? and I couldn't seem to find a good example as to how to correctly use it though.

                  



    Ken Slovak MVP - Outlook
    Wednesday, June 5, 2013 2:42 PM
    Moderator
  • One other thing I can't seem to find is when I create a DASL filter for the unread, for those with potentially 1000s of unread messages, I want to also filter by the restricted SenderEmailAddress list as well, but the only field I can seem to find is the "From" display name.  Is there an equivalent for the SenderEmailAddress for this?
    Thursday, June 6, 2013 1:30 PM
  • The MAPI property PR_SENDER_EMAIL_ADDRESS_W has a DASL tag of "http://schemas.microsoft.com/mapi/proptag/0x0C1F001F".
     
    Using OutlookSpy (www.dimastr.com/outspy) I selected an item in one of my folders and clicked the IMessage button in OutlookSpy. I got the property's DASL property tag that way for you.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "jfalberg" <=?utf-8?B?amZhbGJlcmc=?=> wrote in message news:77299892-01ef-4dc2-82ca-454232654437...
    One other thing I can't seem to find is when I create a DASL filter for the unread, for those with potentially 1000s of unread messages, I want to also filter by the restricted SenderEmailAddress list as well, but the only field I can seem to find is the "From" display name.  Is there an equivalent for the SenderEmailAddress for this?

    Ken Slovak MVP - Outlook
    Thursday, June 6, 2013 2:50 PM
    Moderator
  • Thanks Ken that worked.
    Thursday, June 6, 2013 3:23 PM