This works with a legit user running it. It will need a using statement but your IDE will help you and put it in.
void sendEmail(string strFrom , string strTo , string strSubject , string strBody) {
MailMessage objMailMessage = new MailMessage(); System.Net.NetworkCredential objSMTPUserInfo = new System.Net.NetworkCredential(); SmtpClient objSmtpClient = new SmtpClient();
try { objMailMessage.From = new MailAddress(strFrom); objMailMessage.To.Add(new MailAddress(strTo)); objMailMessage.Subject = strSubject; objMailMessage.Body = strBody;
objSmtpClient = new SmtpClient("172.0.0.1"); /// Server IP objSMTPUserInfo = new System.Net.NetworkCredential ("User name", "Password","Domain"); objSmtpClient.Credentials = objSMTPUserInfo; objSmtpClient.UseDefaultCredentials = false; objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
objSmtpClient.Send(objMailMessage); } catch (Exception ex) { throw ex; }
finally { objMailMessage = null; objSMTPUserInfo = null; objSmtpClient = null; } }
On Wed, Mar 30, 2016 at 6:02 AM, Laurie Alvey trukker41@gmail.com wrote:
I currently use CDO to send email from my apps but I'm thinking of using a .NET component to do it. I have little experience with .NET and none using .NET Interop. I've got Visual Studio Express 14.0 and VFP 9.0 SP2 and would appreciate any pointers.
Laurie
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]