0

I have three problems in C# WinForm application sending email.

1) For sending email, I have to choose the host and port number at runtime e.g. smtp.mail.yahoo.com and port number 465 or smtp.google.com and port number 587. What's the best way to accomplish this?

2) When testing this my antivirus (quick heal) installed on my PC is blocking my application and saying that is not trusted email client. How can I include my application in antivirus / windows trusted email client list programmatically?

3) Is it required that we should use default port 25 or any other port like 465 or 587?

2
  • Where are you pulling the connection details from? Commented Mar 23, 2012 at 11:21
  • I assume that there is away through your antivirus software to tell it that your program is a trusted email client. That would be the only way that could work. Commented Mar 23, 2012 at 15:02

2 Answers 2

1

The class SmtpClient in the namespace System.Net.Mail contains properties for Host and Port.
So there is no problem in setting different ports and hosts. The real port on which you will send your mail depends on the Smtp Service you choose to use.

For the best place how to store the host and port configuration.
It depends on the purpose. Use .config file (application settings) if this is one time configuration needed only during setup process and fixed for all your users. Use config file (user settings) if you want give to each of your users the functionality to change this data during runtime. Also if your application has a database you can consider an Options table with info on configuration.

For the 'programmatically add my application to antivirus'.
I think it's very difficult if possible at all. Security will be severely undermined.
And, in the end, every solution, will depends on a particular API for a particular Antivirus vendor.

Sign up to request clarification or add additional context in comments.

Comments

0
  1. Depends on where/how/what you pull this port data from. Where are you getting the number from?

  2. Well that doesn't matter does it because according to number 1 this will be chosen at runtime!?

2 Comments

2. how can i include my application in antivirus / windows trusted email client list programmatically. read again
Thanks. Edited. Not sure it's possible to that programmatically - would be a huge security risk I'd have thought.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.