For your custom mail you can use this code behind your button:
MailEnvelope objMail = thisApplication.ActiveWindow.MailEnvelope;
objMail.To = "";
objMail.CC = "";
objMail.Subject = "";
objMail.Visible = true;
You can use below class to pass either the users login (samacountname) name, real name (name) or eMail (mail) and retrieve the corresponding manager from active directory. like this you can auto populate the objMail.To already with the manager of the requestor.
using System;
using System.Text;
using System.DirectoryServices;
using System.Collections;
namespace YourNameSpace
{
/// <summary>
/// Summary description for AD_Helper.
/// </summary>
public class AD_Helper
{
string var;
public AD_Helper()
{
}
//1 parameter: what do you path (name, mail etc.), 2nd actual value, third what to you want, so if I liked to get my manager assuming that nukkumatti is my login name I had to call the method like getProperties("samaccountname", nukkumatti, "manager").
public string getProperties(string criteria, string givenValue, string searchValue)
{
try
{
// Create a directory searcher on the path provided when created the instance
DirectoryEntry entry = new DirectoryEntry("LDAP://OU=Husky Users,DC=corp,DC=huskyims,DC=com");
DirectorySearcher searcher = new DirectorySearcher(entry);
string ToFind = "(" + criteria +"=" + givenValue + ")";
searcher.Filter = ToFind;
// Try to find the employee
SearchResult result = searcher.FindOne();
if (result != null)
{
// Get the 'DirectoryEntry' that corresponds to 'result'.
DirectoryEntry myDirectoryEntry = result.GetDirectoryEntry();
// Get the properties of the 'mySearchResult'.
ResultPropertyCollection myResultPropColl;
myResultPropColl = result.Properties;
foreach(Object myCollection in myResultPropColl[searchValue])
{
var = myCollection.ToString();
}
}
}
catch (Exception ex)
{
ex.Message.ToString();
}
return var;
}
}
}