Article View: borland.public.csharpbuilder.language.csharp
Article #454How do I set the recip address in MAPI
From: Ray
Date: Sun, 21 Nov 2004 16:13
Date: Sun, 21 Nov 2004 16:13
56 lines
2774 bytes
2774 bytes
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
Technical Details
Message-ID:
<41a0becb@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!transit.nntp.hccnet.nl!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,82bdb69fbe42010c,start X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Ray" <someone@someisp.net> Newsgroups: borland.public.csharpbuilder.language.csharp Subject: How do I set the recip address in MAPI Date: Sun, 21 Nov 2004 16:13:22 -0000 Lines: 58 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 62.56.16.65 Message-ID: <41a0becb@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1101053643 62.56.16.65 (21 Nov 2004 08:14:03 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!transit.nntp.hccnet.nl!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail