Hello,
I am developing an WFP application under Windows 7 and Outlook 2010. I have following class to send email pragmatically. But I want to prompt send mail windows before sending it, so that user can verify text and if he want he can add/remove and then user send it by clicking send button in send window. I want to know how can I prompt send window after inserting all data pragmatically?
class Email
{
Outlook.Application outlook_app = null; Outlook.MailItem message = null;
Outlook.Recipient recip = null;
Outlook.Attachment attachment = null;
string sSource = "C:\\Users\\{0}\\Downloads\\testi.xlsx";
public Email(string subject, string merkki_malli, string Rek_nro, string recipient, string user)
{
string body = String.Format("Hei!,\n\nHaluamme tilata {0}\nrekisterinumero {1}\nVoitteko vahvistaa sitä? kiitos!\n\nTerveisin,\nMasum", merkki_malli, Rek_nro); outlook_app = new Outlook.Application();
message = (Outlook.MailItem)outlook_app.CreateItem(Outlook.OlItemType.olMailItem);
message.Subject = subject;
message.Body = body;
sSource = String.Format(sSource, user); String sDisplayName = "MyFirstAttachment";
iPosition = (int)message.Body.Length + 1;
int iAttachType = (int)Outlook.OlAttachmentType.olByValue; message.Attachments.Add(sSource, iAttachType, iPosition, sDisplayName);
recip = (Outlook.Recipient)message.Recipients.Add(recipient); recip.Resolve(); }
public void SendEmail()
{
try
{
//Send the message.
message.Save(); message.Send();
//Explicitly release objects.
recip = null;
attachment = null;
message = null;
outlook_app = null;
MessageBox.Show("Sähköpostin lähetys onnistui!");
}
catch (Exception ex)
{
MessageBox.Show("Sähköposti lähetys epäonnistui!");
}
}
}Do it now! - Today will be yesterday tomorrow MadSum