title: MAPISendMail with Outlook sometimes results in winmail.dat
body: <p>I am using <strong>MAPISendMail()</strong> in an MFC application, and am having a problem that webmail clients sometimes receive a winmail.dat attachment, instead of the "real" attachments.</p>
  
  <p>I have researched a lot, and have found that others are experiencing this problem too, but have not found a solution.</p>
  
  <p>I believe that the problem may be in my <strong>MapiFileDesc</strong> structure, in which I leave the lpFileType member pointing to NULL, in order to have the mail program (In my case Outlook 2010) determine the file type automatically.
  <strong>lpFiletype</strong> is a <strong>MapiFileTagExt</strong> structure, and the documentation says this:
  <em>A value of NULL indicates an unknown file type or a file type determined by the operating system.</em></p>
  
  <p>So I believe this should work for common types, such as JPEG or GIF and such.</p>
  
  <p>I read that the winmail.dat is caused by Outlook sending the mail encoded with the <strong>ms-tnef</strong> encoding, which is proprietary to Microsoft. However, when sending the email, Outlook shows "HTML" as highlighted, not RTF.</p>
  
  <p>Has anyone encountered this problem and properly solved it? </p>
  
  <p>Sending via SMTP and such is not an option, because the user should have a copy of the message in their Sent Items folder.
  Using the Outlook object model is not an option, because that would require the user has Outlook installed, and not any MAPI compatible client.</p>