SImple MAPI use of attached files

My question deals with using the Simple MAPI function,
MAPISendMail in Visual C++ 5.0.  Within the MapiMessage struct
there is the following member;
lpMapiFileDesc - Pointer to an array of MapiFileDesc structures,
each containing information about a file attachment.
Within the MapiFileDesc there is the following pointer,
lpFileType - Pointer to the attachment file type,
which can be represented with a MapiFileTagExt structure.  
Within the MapiFileTagExt struct there are the following members;

cbTag - The size, in bytes, of the value defined by the lpTag member.

lpTag - Pointer to an X.400 object identifier indicating the type of the attachment
in its original form, for example "Microsoft Excel worksheet".

cbEncoding - The size, in bytes, of the value defined by the lpEncoding member.

lpEncoding - Pointer to an X.400 object identifier indicating the form in which
the attachment is currently encoded, for example MacBinary, UUENCODE, or binary.

Now my question, where do I find the values/data for the above.
These are X.400 Object IDs or OIDs.  I need an example on for
attaching a standard .txt file that can be viewed in
Notepad.  My attachment is unreadalbe when opened from a browser.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you look in this file MAPITAGS.H ?
CmustaffaAuthor Commented:
Yes, I've looked in MAPITAGS.H.  I think MAPIOID.H contains a few OIDs
but I not sure how to use them.  Those
fields require X.400 OIDs. The OID
fields are defined as LPBYTE and the
lengths as ULONG.  But the length fields
give an example of "Microsoft Excel worksheet", do I get the lenght with this;
char szFileType = "Microsoft Excel..";
ULONG uLength = strlen(szFileType);
LPBYTE pFileType = X.400 OID for Excel?
may be this way?
I find this in msdn

MapiFileTagExt (Simple MAPI)
A MapiFileTagExt structure specifies a message attachment's type at its creation and its current form of encoding so that it can be restored to its original type at its destination.

Quick Info
Header file: MAPI.H

typedef struct {
     ULONG ulReserved;
     ULONG cbTag;
     LPBYTE lpTag;
     ULONG cbEncoding;
     LPBYTE lpEncoding
} MapiFileTagExt, FAR *lpMapiFileTagExt;
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

CmustaffaAuthor Commented:
You didn't answer the question!  What
are the values that are used in the following fields;
ULONG cbTag;
ULONG cbEncoding;
LPBYTE lpEncoding
Cmustaffa, you don't need X.400 protocol
for usually text file!
Next is an simple example sending mail with attached file:
  HRESULT hRes;// = S_OK;
  ULONG ulReserved = 0L;
  LPSTR lpszFileName = NULL,
  lpszPathName = NULL;
  char   szErr[256];
  char lpszFullPath[256] = {NULL};

  lpMapiRecipDesc pRecips = NULL;
  MapiMessage Message;
  MapiFileDesc pFileDesc;

  ZeroMemory ( &Message, sizeof ( MapiMessage ) );
  ZeroMemory ( &pFileDesc, sizeof ( MapiFileDesc ) );

  if ( m_lhSession )       // Always check to make sure there is an active session
            // Populate members of Message structure.
      char lpszName[255],szSubject[255];

      cResolveName ( lpszName, &pRecips );
      Message.nRecipCount  = 1L; // Must be set to the correct number of recipients.
      pRecips->ulRecipClass = MAPI_TO;
      Message.lpRecips         = pRecips;      // Address of list of names returned from MAPIAddress.

            // Capture the file name and path name. strcat the file name to the end of the
            // path name
      strcat ( lpszFullPath, szDir );
      strcat ( lpszFullPath, szFileName );

            // Set the file and path name members of the MapiFileDesc.
      pFileDesc.lpszFileName = szFileName;
      pFileDesc.lpszPathName = lpszFullPath;

            // Set the other members of the MapiMessage structure.
                  // We only support 1 attachment so nFileCount gets set to 1.
      Message.ulReserved     = ulReserved;
      strcpy(szSubject, "Name");

      Message.lpszSubject    = ( LPTSTR ) szSubject;
      Message.lpszNoteText   = ( LPTSTR ) szMessage;
      Message.lpOriginator   = NULL;
      Message.nFileCount     = 1L;
      Message.lpFiles           = &pFileDesc;

      hRes = m_MAPISendMail (m_lhSession,      // Global session handle.
                       0L,            // Parent window. Set to 0 since console app.
                       &Message,             // Address of Message structure
                       ulReserved);       // Reserved. Must be 0L.

      if ( hRes == SUCCESS_SUCCESS )
I hope, it helps. Alex

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CmustaffaAuthor Commented:
Alex, I can get the attachment to correctly detach if the recipient is
using MS OutLook, i.e., the attactment
appear as a Notepad icon at the bottom
of the file.  The problem is when I email the attachment with the name; or or to any non-MS mailer
program the attachment appears as "Unknown" file type in aol and detaches
as garbage in hotmail. I think these environments need the X.400 OID tags
to properly decode and detach the .txt
files.  I found the X.400 OIDs on the Internet for Microsoft's file formats
and the mapioid.h contains a few OIDs,
but trying to use the macros to create
an OID BYTE tag generated errors. I \
believe that the MapiFileTagExt struct
is used for non-MS environments, why else would it be included?  Thanks for
P.S. I found nothing on MSDN or KB KB    
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.