1

What I ask is not possible I think, but I ask in case it could be. I am using .NET Framework 4 on VS 2010 and Outlook 2003.

I want to send email through outlook. But I want to specify send from like newMail.SendUsingAccount command in later versions and also this send from account is not in outlook accounts. Is this possible?

I have this code

Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem oMsg = (Outlook.MailItem) oApp.CreateItem(Outlook.OlItemType.olMailItem); // Create a new mail item.

oMsg.HTMLBody = "Hello, NXYLO your message body will go here!!"; // Set HTMLBody. 

String sDisplayName = "MyAttachment";
int iPosition = (int) oMsg.Body.Length + 1;
int iAttachType = (int) Outlook.OlAttachmentType.olByValue;
Outlook.Attachment oAttach = oMsg.Attachments.Add(TBattachment.Text, iAttachType, iPosition, sDisplayName); //Add an attachment.

oMsg.Subject = "Your Subject will go here."; //Subject line
oMsg.Importance = Outlook.OlImportance.olImportanceNormal;

Outlook.Recipients oRecips = (Outlook.Recipients) oMsg.Recipients;
Outlook.Recipient oRecip = (Outlook.Recipient) oRecips.Add(TBrecipient.Text); // Add a recipient.
oRecip.Resolve();
// Send.
oMsg.SaveAs(@"C:\Nxylo\mail.msg");
((Outlook._MailItem) oMsg).Send(); // oMsg.Send() Ambiguity between method 'Microsoft.Office.Interop.Outlook._MailItem.Send()' and non-method 'Microsoft.Office.Interop.Outlook.ItemEvents_10_Event.Send'. Using method group.
// Clean up.
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
0m3r
  • 12,286
  • 15
  • 35
  • 71
vicangel
  • 162
  • 2
  • 18

0 Answers0