D
Devhead
I am trying to send email via Outlook Object 10 library. When I click Send,
the mail item closes but the email never gets delivered. when i open
Outlook, i discover that the inbox is littered with the messages that i
attempted to send. Why did theses messages not get delivered? Also, how can
i bring up a non-modal email window and still have it disposed of when user
either clicks Send or closes email message window? thanks.
Here my code:
msgTo = "(e-mail address removed)";
msgFrom = "(e-mail address removed)";
msgSubject = "Test Document Email";
msgBody = "Body of the message";
msgIncAtt = true;
SendEmail();
public static void SendEmail()
{
// Create the Outlook application
oOutlook = new Outlook.Application();
//Create the new message
oMsg = (Outlook.MailItem)oOutlook.CreateItem(Outlook.OlItemType.olMailItem);
//Set the basic properties.
oMsg.To = msgTo;
oMsg.Subject = msgSubject;
oMsg.CC = msgCC;
oMsg.Body = msgBody;
if (msgIncAtt)
{
//Add an attachment.
object sSource = FilePath;
object sDisplayName = "Test Document";
object iPosition = (int)oMsg.Body.Length + 1;
object iAttachType = (int)Outlook.OlAttachmentType.olByValue;
oAttach = oMsg.Attachments.Add(sSource,iAttachType,iPosition,sDisplayName);
}
oMsg.Save();
oMsg.Display(true);
}
the mail item closes but the email never gets delivered. when i open
Outlook, i discover that the inbox is littered with the messages that i
attempted to send. Why did theses messages not get delivered? Also, how can
i bring up a non-modal email window and still have it disposed of when user
either clicks Send or closes email message window? thanks.
Here my code:
msgTo = "(e-mail address removed)";
msgFrom = "(e-mail address removed)";
msgSubject = "Test Document Email";
msgBody = "Body of the message";
msgIncAtt = true;
SendEmail();
public static void SendEmail()
{
// Create the Outlook application
oOutlook = new Outlook.Application();
//Create the new message
oMsg = (Outlook.MailItem)oOutlook.CreateItem(Outlook.OlItemType.olMailItem);
//Set the basic properties.
oMsg.To = msgTo;
oMsg.Subject = msgSubject;
oMsg.CC = msgCC;
oMsg.Body = msgBody;
if (msgIncAtt)
{
//Add an attachment.
object sSource = FilePath;
object sDisplayName = "Test Document";
object iPosition = (int)oMsg.Body.Length + 1;
object iAttachType = (int)Outlook.OlAttachmentType.olByValue;
oAttach = oMsg.Attachments.Add(sSource,iAttachType,iPosition,sDisplayName);
}
oMsg.Save();
oMsg.Display(true);
}