Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than mapi32, prefix the name with the module name and a period.
MAPISendMail (mapi32)
.
C# Signature:
/// <summary>
/// The MAPISendMail function sends a message.
///
/// This function differs from the MAPISendDocuments function in that it allows greater
/// flexibility in message generation.
/// </summary>
[DllImport("MAPI32.DLL", CharSet=CharSet.Ansi)]
public static extern uint MAPISendMail(IntPtr lhSession, IntPtr ulUIParam,
MapiMessage lpMessage, uint flFlags, uint ulReserved);
VB Signature:
<DllImport("MAPI32.DLL")> _
Private Shared Function MAPISendMail(ByVal sess As IntPtr, ByVal hwnd As IntPtr, ByVal message As MapiMessage,
ByVal flg As Integer, ByVal rsv As Integer) As Integer
End Function
This signature is valid, if the MapiMessage is defined as a class. If MapiMessage is defined as a structure a 'ref' has to be added before 'MapiMessage lpMessage' parameter
[DllImport("MAPI32.DLL")]
static extern int MAPISendMail(IntPtr sess, IntPtr hwnd, MapiMessage message, int flg, int rsv);
public int SendMail(string fileName)
{
MapiMessage msg = new MapiMessage();
msg.subject = "Hello World!";
msg.noteText = "See attached file for details";
msg.files = GetAttachments(fileName, out msg.fileCount);
int result = MAPISendMail(new IntPtr(0), new IntPtr(0), msg, 0x00000001 | 0x00000008, 0);
if (result > 1 || result < 0)
throw new System.InvalidOperationException();
return result;
}
IntPtr GetAttachments(string fileName, out int fileCount)
{
int size = Marshal.SizeOf(typeof(MapiFileDesc));
IntPtr intPtr = Marshal.AllocHGlobal(size);
MapiFileDesc mapiFileDesc = new MapiFileDesc();
//An integer used to indicate where in the message text to render the attachment.
mapiFileDesc.position = -1;
int ptr = (int)intPtr;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class MapiMessage
{
public int reserved;
public string subject;
public string noteText;
public string messageType;
public string dateReceived;
public string conversationID;
public int flags;
public IntPtr originator;
public int recipCount;
public IntPtr recips;
public int fileCount;
public IntPtr files;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class MapiFileDesc
{
public int reserved;
public int flags;
public int position;
public string path;
public string name;
public IntPtr type;
}
Alternative Managed API:
Do you know one? Please contribute it!
MAPISendMail - Sends a message.
11/18/2013 4:54:10 AM - -66.153.46.146
TODO - a short description
2/22/2011 12:48:46 PM - anonymous
TODO - a short description
2/22/2011 12:48:46 PM - anonymous
TODO - a short description
2/22/2011 12:48:46 PM - anonymous
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).