Hello,
I'm trying to use MAPI with a web service in C#, I'm trying to use this MAPI33.dll found at
http://www.mapi33.adexsolutions.com but i can't figure out how to set it up for use with a webservice.
NOTE: this works as a console application.
here's the code, it just tries to send an email.
-------------------------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using MAPI33;
namespace WebService1
{
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
}
#region Component Designer generated code
//Required by the Web Services Designer
private IContainer components = null;
private void InitializeComponent()
{
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
[WebMethod]
public string MAPITest()
{
try
{
Error hr;
IMAPISession session;
// Initialise MAPI interface driver
MAPIINIT map = new MAPIINIT();
map.Flag = MAPIINIT.FLAGS.NTService;
hr = MAPI.Initialize(map);
string[] problems;
hr = MAPI.LogonEx(IntPtr.Zero, "username", "pass",
MAPI.FLAGS.NTService
| MAPI.FLAGS.NoMail
| MAPI.FLAGS.NewSession
| MAPI.FLAGS.ExplicitProfile,
out session);
MAPI33.Helpers.Message.Send(
MAPI33.Helpers.Message.SendFlags.CopyToSentItems,
session,
new string[] {"
[email protected]"},
null,
null,
"WEBService Test",
"test",
null,
out problems
);
MAPI.Uninitialize();
}
catch (System.Exception e)
{
return e.ToString();
}
return "success";
}
}
}