1 – 3 of 3
Blogger Spencer said...

You could just *write* a managed MAPI wrapper. ;)

23 January, 2009 16:51

Blogger Yakko Warner said...

Eh, more or less, that's what the code from CodeProject amounts to, which should suffice for this project.

As long as nothing goes wrong with all this "marshaling to an unmanaged DLL" crap...

23 January, 2009 17:04

Blogger Can Günaydın said...

hi
i read the codeproject article and i was using this class in my .Net application it was working fine with outlook express but i have some problems with windows live mail. Sendmailpopup method doesn't working it just only open windows live mail application and nothing happens. Also i try to take this process to another thread but nothing change.Sometimes after windows live mail opening it gives general mapi failure error [2]. I could send mail messages directly but this is not what i want, do you have any idea why is this happening? because i am stuck. Any help would be appreciated.

here is my code:

private void btnComposeEmail_Click(object sender, EventArgs e)
{
//EmailPopup();
ActionThread = new Thread(EmailPopup);
ActionThread.Priority = ThreadPriority.Normal;
ActionThread.SetApartmentState(ApartmentState.STA);
ActionThread.Start();

}

private void EmailPopup()
{
try
{
//GridAttachments
MAPI mapi = new MAPI();
Boolean IsErrorExist = false;
if (gridOfferReport.Rows.Count > 0)
{
foreach (DataGridViewRow dgr in gridOfferReport.Rows)
{
mapi.AddAttachment(Convert.ToString(dgr.Cells["OfferReportPath"].Value));
}

}
else
IsErrorExist = true;

foreach (DataGridViewRow dgr in gridAttachments.Rows)
{
if (dgr.Cells["AttachmentChkColumn"].Value != null)
{
if (((bool)dgr.Cells["AttachmentChkColumn"].Value) == true)
{
mapi.AddAttachment(Convert.ToString(dgr.Cells["AttachmentPath"].Value));
}

}
}


//GridTo
foreach (DataGridViewRow dgr in gridTo.Rows)
{
if (dgr.Cells["ToChkColumn"].Value != null)
{
if (((bool)dgr.Cells["ToChkColumn"].Value) == true)
{
if (Convert.ToString(dgr.Cells["ToMail"].Value) != "")
mapi.AddRecipientTo(Convert.ToString(dgr.Cells["ToMail"].Value));
else
IsErrorExist = true;


}

}
}

//GridCC

foreach (DataGridViewRow dgr in gridCC.Rows)
{
if (dgr.Cells["CCChkColumn"].Value != null)
{
if (((bool)dgr.Cells["CCChkColumn"].Value) == true)
{
if (Convert.ToString(dgr.Cells["CCMail"].Value) != "")
mapi.AddRecipientCC(Convert.ToString(dgr.Cells["CCMail"].Value));
else
IsErrorExist = true;
}

}
}
if (IsErrorExist == true)
{
MessageBox.Show("Seçtiğiniz kişilerden en az birinin email adresi bulunmamaktadır veya Teklif oluşturmadınız.");
mapi = null;
}
else
mapi.SendMailPopup(myOffer._Project.Name, myOffer._Project.Subject);
}
catch (Exception ex)
{

}
finally
{

ActionThread.Abort();
ActionThread.Join();
}

}

04 September, 2009 17:30

Your civil comments are appreciated. Thanks!
You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot