MAPI problem
From: Ray (rlewis_at_beeb.net)
Date: 11/22/04
- Next message: Howard Swope: "Re: Convert InProcServer to OutProc"
- Previous message: Tom wilson: "Re: Excel using ado.net - operation must use an updateable query"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 22 Nov 2004 20:35:32 -0000
Hi
How do you set the address in MAPI. The code below sends the message to SMTP
server ok with the correct subject and text, but I can't quite figure out
how to get the address right.
public void DoMail(String addr,String msg, String subj)
{
MapiMessage message=new MapiMessage();
MapiRecipDesc recipDesc =new MapiRecipDesc();
message.lpOriginator=recipDesc.lpEntryID;
message.lpszNoteText=msg;
message.lpszSubject=subj;
recipDesc.lpszAddress=addr;
MAPISendMail (IntPtr.Zero, IntPtr.Zero, message, MAPI_LOGON_UI, 0);
}
I guess that the problem is with the line
message.lpOriginator=recipDesc.lpEntryID;
I am doing the following declarations:
public const uint MAPI_LOGON_UI = 0x00000001;
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public class MapiMessage
{
public uint ulReserved = 0;
public string lpszSubject = string.Empty;
public string lpszNoteText = string.Empty;
public string lpszMessageType = null;
public string lpszDateReceived = DateTime.Now.ToString("yyyy/MM/dd hh:mm");
public string lpszConversationID = string.Empty;
public uint flFlags = 0;
public IntPtr lpOriginator = IntPtr.Zero;
public uint nRecipCount = 0;
public IntPtr lpRecips = IntPtr.Zero;
public uint nFileCount = 0;
public IntPtr lpFiles = IntPtr.Zero;
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public class MapiRecipDesc
{
public uint ulReserved = 0;
public uint ulRecipClass = MAPI_ORIG;
public string lpszName = string.Empty;
public string lpszAddress = string.Empty;
public uint ulEIDSize = 0;
public IntPtr lpEntryID = IntPtr.Zero;
}
[DllImport("MAPI32.DLL", CharSet=CharSet.Ansi)]
public static extern uint MAPISendMail(IntPtr lhSession, IntPtr ulUIParam,
MapiMessage lpMessage, uint flFlags, uint ulReserved);
Ray
- Next message: Howard Swope: "Re: Convert InProcServer to OutProc"
- Previous message: Tom wilson: "Re: Excel using ado.net - operation must use an updateable query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|