J
Jax
Behold the code that doesnt work
using System
using Outlook
namespace EmailAp
/// <summary
/// Summary description for SendingEmail
/// </summary
public class SendingEmai
public SendingEmail(
/
// TODO: Add constructor logic her
/
[STAThread
static void Main(string[] args
Console.WriteLine("Sending e-mail")
string s = SendingEmail.SendEmail("(e-mail address removed)", "someSubject", "Blah blah")
Console.WriteLine("Return message is: " + s)
Console.ReadLine()
public static string SendEmail(string to, string subject, string text
Outlook.Application ol
Outlook.NameSpace ns
Outlook.MailItem objmail
tr
//Open Namespac
ol = new Outlook.Application()
ns = ol.GetNamespace("MAPI")
ns.Logon("", "", false, true)
objmail = (Outlook.MailItem) ol.CreateItem(Outlook.OlItemType.olMailItem)
objmail.To = to
objmail.Body = text
objmail.Subject = subject
objmail.Send()
}
catch(System.Exception e
return e.ToString()
return "Success"
Dont get me wrong, this does work, but only on my p.c. I copy it across to a work colleage and it doesn't work at all
What permissions doe I need to observe? Is it something I have to set up in windows? Or can I fix thisfrom code by using a different constructor or something
I want to use this code to send me eMails whenever an exception occurs in my program so I can assess performance when others are using it, is there a better method than this
Many thanks for any assistanc
jax
using System
using Outlook
namespace EmailAp
/// <summary
/// Summary description for SendingEmail
/// </summary
public class SendingEmai
public SendingEmail(
/
// TODO: Add constructor logic her
/
[STAThread
static void Main(string[] args
Console.WriteLine("Sending e-mail")
string s = SendingEmail.SendEmail("(e-mail address removed)", "someSubject", "Blah blah")
Console.WriteLine("Return message is: " + s)
Console.ReadLine()
public static string SendEmail(string to, string subject, string text
Outlook.Application ol
Outlook.NameSpace ns
Outlook.MailItem objmail
tr
//Open Namespac
ol = new Outlook.Application()
ns = ol.GetNamespace("MAPI")
ns.Logon("", "", false, true)
objmail = (Outlook.MailItem) ol.CreateItem(Outlook.OlItemType.olMailItem)
objmail.To = to
objmail.Body = text
objmail.Subject = subject
objmail.Send()
}
catch(System.Exception e
return e.ToString()
return "Success"
Dont get me wrong, this does work, but only on my p.c. I copy it across to a work colleage and it doesn't work at all
What permissions doe I need to observe? Is it something I have to set up in windows? Or can I fix thisfrom code by using a different constructor or something
I want to use this code to send me eMails whenever an exception occurs in my program so I can assess performance when others are using it, is there a better method than this
Many thanks for any assistanc
jax