3 Replies Latest reply on Feb 4, 2008 4:25 PM by Applied CD

    Opening Outlook with pre-populated subject line and attachments

    Applied CD Level 1
      I’ve got a button that opens a new Outlook email message and attaches a specified PDF (code below). I’d also like to pre-populate the subject line but I can’t find a way using the command line approach. I know a subject line can be added using the more conventional mailto:URL approach but in this case I can’t automatically attach the PDFs. The direcEmail xtra isn’t an option, the program will have to operate in a locked down, tight security environment where all standard ports have been closed. The client’s IT department has specified that all in and outbound email traffic must be routed through Outlook which they configure to navigate through their exchange and proxy servers.
        • 1. Re: Opening Outlook with pre-populated subject line and   attachments
          Level 7
          Not only do you lack a subject line, but it looks as though there is no
          To: field specified either. Does the documentation you found for the "
          /a " switch not provide a switch for the to: and subject: fields?
          • 2. Re: Opening Outlook with pre-populated subject line and   attachments
            Applied CD Level 1
            The following link is Microsoft’s list of switches for Outlook 2007. According to this list the /m address switch should allow you to specify the To: field, however, I couldn’t get it to work with Office 2003 (the list says to use the /m switch you must also use the /c ipm.note switch but I couldn’t get it to work either way). I found an old article that made mention of a /mailto switch that accepted normal URL encoding for all of the header fields (including Subject: ) but I couldn’t get that to work either (and since it’s not on the 2007 list I’m guessing it might not be the best choice anyway). Fortunately in my case the recipient will always be changing so the only field I’d like to populate would be the subject line (Outlook’s config takes care of the From: field).

            The /a switch has been around for a while, I’ve seen it mentioned in articles as old as 2001, we only need to support Office 2003 and later.

            http://office.microsoft.com/en-us/outlook/HP012185891033.aspx
            • 3. Re: Opening Outlook with pre-populated subject line and attachments
              Applied CD Level 1
              Got it working (but it needs serious testing)…

              The /m switch works and supports all of the header fields but it conflicts with the /recycle switch which is on by default (at least on my system). I’ve added a line that strips all of the switches from the reg supplied cmd string and adds /c and /m. Apparently, any path strings after /m are recognized as attachments and the /a switch must be removed to function. It remains to be seen if stripping all of the switches is safe, on my system /recycle was the only switch on by default.

              Note: all of the header fields are optional.