//////////////////////////////////////////////////////////////////////////////////////////////////////////// // // To embed images inside of HTML text: // -send a message as usual, setting its HTML text // -add an <IMG tag with src="cid:<contentID>" // -add an attachment using the same CID // //////////////////////////////////////////////////////////////////////////////////////////////////////////// public static void SendCIDTest(NetMAPI mapi) { if (mapi.OpenOutbox()) { MAPIMessage message = new MAPIMessage(); if (message.Create(mapi, MAPIMessage.Importance.IMPORTANCE_LOW)) { message.SetSender("Support", "*****@*****.**"); message.SetSubject("Subject"); string strCID = "123456789"; StringBuilder strImage = new StringBuilder(); strImage.Append("<html><body><IMG alt=\"\" src=\"cid:"); strImage.Append(strCID); strImage.Append("\" border=0></body></html>"); message.SetRTF(strImage.ToString()); message.AddRecipient("*****@*****.**"); message.AddAttachment(@"c:\Temp\Pic.jpg", "", strCID); // obviously you'll have to supply an image here if (message.Send()) { Console.WriteLine("Sent Successfully"); } } } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////// // // To send a message: // -first open up a MAPI session and login // -then open the message store you want to access // -then open the outbox // -create a new message, set its priority if you like // -set its properties, recipients and attachments // -call send // //////////////////////////////////////////////////////////////////////////////////////////////////////////// public static void SendTest(NetMAPI mapi) { if (mapi.OpenOutbox()) { MAPIMessage message = new MAPIMessage(); if (message.Create(mapi, MAPIMessage.Importance.IMPORTANCE_LOW)) { message.SetSender("Support", "*****@*****.**"); message.SetSubject("Subject"); // user SetBody for ANSI text, SetRTF for HTML and Rich Text message.SetRTF("<html><body><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial;color:red'>Body</font></body></html>"); message.AddRecipient("*****@*****.**"); message.AddRecipient("*****@*****.**"); if (message.Send()) { Console.WriteLine("Sent Successfully"); } } } }