locked
Blank line at the top of MAPI generated message when adding attachments RRS feed

  • Question

  • Hi,

    I'm trying to create a simple plain text message with one single attachment using MAPI's legacy MAPISendMail (ansi) function. The email client on the test platform (and the one typically, but not necessarily all the time) being used is Outlook 2010.

    Everything goes fine aside from that there is an additional annoying blank line at the top of the generated message (before any text would appear). If there is no attachment specified, the email looks fine (there is no blank line).

    What do you recommend? Should I go for the newer API's like MAPISendMailW or the helper function introduced in Windows 8/Vista?

    Also let me know if for some reason it is better to use the ShellExecute API with a mailto:... link - we need to attach a file, and formerly this wasn't said to be well-supported. Does it have better support now?

    Our minimum target platform can be estimated as Windows 7 but it's always nice to be backward compatible.

    Thank you!

    Janos

    • Edited by janca Wednesday, March 12, 2014 1:18 PM
    Wednesday, March 12, 2014 1:17 PM

All replies

  • Hello Janos,

    Why do you need to use Simple MAPI functions for creating mail items with attachments?

    The Outlook object model provides all the required properties and methods for this. You may find the following articles helpful:

    How to automate Outlook and Word by using Visual C# .NET to create a pre-populated e-mail message that can be edited

    How to automate Outlook from another program

    Also MSDN library provides a lot of HOWTO articles related to Outlook. See How to: Attach a File to a Mail Item.

    If you use Visual Basic, see PRB: Simple MAPI BMAPI Functions May Not Work from Visual Basic Code.
    Wednesday, March 12, 2014 2:05 PM
  • Hello Eugene,

    Thank you for the quick reply.

    MAPI happened to be the choice because the solution should (as far as this comes at a reasonable price) not only support Outlook, but various email clients. The target will probably often be Outlook, though, which is likely to make the problem apparent.

    With regard to the choice of Simple MAPI - it is just something for which there were tons of examples for Delphi (which the target environment is), or C++ (which I can try and see if works, also port to Delphi with relative ease). Also it almost does the job (some might take it as it doesn't :) but it's really nearly there).

    I personally would guess it seems plausible that whoever implemented the more complicated Extended MAPI, also chosen to maintain Simple MAPI as a facade over the new implementation. Based on this guess (which can easily be incorrect) chances are even if I switch to the new API's, the problem will persist (but who knows), so I didn't push that too much and thought it was better to ask. (Maybe there is some known workaround?)

    Kind regards,

    Janos

    Wednesday, March 12, 2014 3:15 PM
  • Wednesday, March 12, 2014 4:31 PM
  • Hello Janos,

    This needs further investigation and also requires more in-depth level of support. Please visit the below link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone  
    A normal incident is required for us to engage our Escalation to work out this issue with product team to sort out. If we determine that the issue is the result of a product issue, then the service request will be a No-Charge case and you won't be charged.

    Thanks for your understanding.

    Friday, March 21, 2014 1:01 AM