Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm trying to send emails to an outlook accounts witn the folowing code..
C#
Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem email = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
email.Recipients.Add("hari.prasad@fnu.ac.fj");
email.Subject = "TestSubject";
email.Body = "TestBody";
((Outlook.MailItem)email).Send();

The message does get send but at the receivers end im getting a waring say..
a programm is trying to access e-mail infromation stored in Outlook.If this is unexpected,click deny......n so on..

Now once i allow this then only the message is receive..N this is what i dont want...Is there a better way of doing this or how can i inprove to avoid this kind of message.
Posted
Updated 10-Oct-12 10:43am
v3
Comments
Sergey Alexandrovich Kryukov 10-Oct-12 18:53pm    
If you sent to Outlook, not from, what's the difference where you send it? You send to e-mail address, not a server or a client...
--SA

1 solution

Why are you doing it that way. The accepted way would be like this:
C#
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("emailAddress@yourPlace.com");
message.Subject = "Put a subject here";
message.From = new System.Net.Mail.MailAddress("emailFromAddress@someplace.com");
message.Body = "Put your message here";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");
smtp.Send(message);
 
Share this answer
 
Comments
RaisKazi 10-Oct-12 17:05pm    
Agree!
fjdiewornncalwe 10-Oct-12 17:08pm    
Thanks Rais.
Member 9291223 10-Oct-12 17:25pm    
thanks but even after doing this the mail is not delivered to my inbox...or may be im using a wrong smpthost
fjdiewornncalwe 10-Oct-12 17:30pm    
Possibly. Without that being configured correctly nothing will work.
Member 9291223 10-Oct-12 17:34pm    
Im quite sure that im using the correct host..My host "mail.fnu.local".If im not wrong then this is the way to put down the host right..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900