473,394 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Sending emails via c# code

Hi all,

I have googled this and found some answers but none that give me exactly
what I'm after, maybe someone here can help.

I have an app that will be distributed to users for their laptop and
home PC's, I have no idea what operating system they are using although
it will be at least Win 98, I also have no idea what mail client they
will be using or which ISP their mail account is with. I would like to
send an email from the app using their default mail account, I had a
look at the System.Web.Mail classes, specifically MailMessage class, but
this requires a mail server, how would I get this information from the
system? also it requires a mail from field which I would like to get
from the system without asking the user to enter it, again how is this
achieved?

Is there another way to do what I want to do, I know that there are the
Indy components but I'd rather avoid having to distibute more Dll's,
unless the Indy route is the best.

The only thing I can guarantee is that the target machine that this app
is installed on will have a mail account.

Many thanks

Joe
Nov 17 '05 #1
12 1482
I would build the SMTP server property as configurable in your application.

Try and standardise the from address if possible - maybe use the machine
name or currently login name.

"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi all,

I have googled this and found some answers but none that give me exactly
what I'm after, maybe someone here can help.

I have an app that will be distributed to users for their laptop and home
PC's, I have no idea what operating system they are using although it will
be at least Win 98, I also have no idea what mail client they will be
using or which ISP their mail account is with. I would like to send an
email from the app using their default mail account, I had a look at the
System.Web.Mail classes, specifically MailMessage class, but this requires
a mail server, how would I get this information from the system? also it
requires a mail from field which I would like to get from the system
without asking the user to enter it, again how is this achieved?

Is there another way to do what I want to do, I know that there are the
Indy components but I'd rather avoid having to distibute more Dll's,
unless the Indy route is the best.

The only thing I can guarantee is that the target machine that this app is
installed on will have a mail account.

Many thanks

Joe

Nov 17 '05 #2
Adam Barker wrote:
I would build the SMTP server property as configurable in your application.
"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

Hi Adam,

Hmmm, I'd like to think the users would have the abilty to do enter the
smtp server details :-), however our target audience wont really be that
computer literate. Also the only time the email part of the app will be
needed is when they register their software, so ideally I'd like it to
be a simple case of click and go for them.
Try and standardise the from address if possible - maybe use the
machine name or currently login name.


Does this mean that the from address does not have to be a valid email
address? i.e.

Their actual email is
so*****@ansmtpserver.com

but the from address in the MailMessage object could be set to
re**********@adomain.com

Many thanks
Joe
Nov 17 '05 #3
I can't see how you could cope with all the different configurations without
programmatically checking properties of an Outlook profile for example. Even
this relies on the user using Outlook.

You could make the app ask for the server after first installing and then
never bother the user again. Then you just need to let the user know the
details required, i.e. their SMTP server. (If you know their IP, you could
look this up in advance to help them)

The 'from' address is your choice to a certain extent. Admittedly I've only
used a custom address when I've been in control of the SMTP server itself
and can enable relaying etc.

"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Adam Barker wrote:
I would build the SMTP server property as configurable in your
application.
"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...


Hi Adam,

Hmmm, I'd like to think the users would have the abilty to do enter the
smtp server details :-), however our target audience wont really be that
computer literate. Also the only time the email part of the app will be
needed is when they register their software, so ideally I'd like it to be
a simple case of click and go for them.
Try and standardise the from address if possible - maybe use the machine
name or currently login name.


Does this mean that the from address does not have to be a valid email
address? i.e.

Their actual email is
so*****@ansmtpserver.com

but the from address in the MailMessage object could be set to
re**********@adomain.com

Many thanks
Joe

Nov 17 '05 #4
Adam Barker wrote:
I can't see how you could cope with all the different configurations without
programmatically checking properties of an Outlook profile for example. Even
this relies on the user using Outlook.

You could make the app ask for the server after first installing and then
never bother the user again. Then you just need to let the user know the
details required, i.e. their SMTP server. (If you know their IP, you could
look this up in advance to help them)

The 'from' address is your choice to a certain extent. Admittedly I've only
used a custom address when I've been in control of the SMTP server itself
and can enable relaying etc.

"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...


I see the problem, what about this then:

Can I find the default mail account, and tell it to create an email with
my email address, subject and body in it. This would negate the need to
know any settings for SMTP etc. but would rely instead on an external
app, like outlook express for instance. This would also mean if the user
had a hotmail account that does not use SMTP my app could still send the
email, although the user themselveswould have to click "Send".

Thanks

Joe
Nov 17 '05 #5
I would've said it was far easier to use MailMessage than to start checking
for mail profiles. Outlook these days is quite locked down security wise so
I'm not sure how automatic you could make this. I would almost definitely go
for prompting for the smtp server.

Depending on the context on which you're developing this app, could you not
use your own SMTP server and therefore hardcode this address in your app?
This way a) you wouldn't need to worry about the user knowing any mail
information, and b) you could enable relaying.

"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
Adam Barker wrote:
I can't see how you could cope with all the different configurations
without programmatically checking properties of an Outlook profile for
example. Even this relies on the user using Outlook.

You could make the app ask for the server after first installing and then
never bother the user again. Then you just need to let the user know the
details required, i.e. their SMTP server. (If you know their IP, you
could look this up in advance to help them)

The 'from' address is your choice to a certain extent. Admittedly I've
only used a custom address when I've been in control of the SMTP server
itself and can enable relaying etc.

"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...


I see the problem, what about this then:

Can I find the default mail account, and tell it to create an email with
my email address, subject and body in it. This would negate the need to
know any settings for SMTP etc. but would rely instead on an external app,
like outlook express for instance. This would also mean if the user had a
hotmail account that does not use SMTP my app could still send the email,
although the user themselveswould have to click "Send".

Thanks

Joe

Nov 17 '05 #6
"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
The only thing I can guarantee is that the target machine that this app is
installed on will have a mail account.


Can you also guarantee that the target machine will have Internet accesss?
If so, why not abandon the email approach altogether and write a webservice
which the target machines will connect to?
Nov 17 '05 #7
Adam Barker wrote:
I would've said it was far easier to use MailMessage than to start checking
for mail profiles. Outlook these days is quite locked down security wise so
I'm not sure how automatic you could make this. I would almost definitely go
for prompting for the smtp server.

Depending on the context on which you're developing this app, could you not
use your own SMTP server and therefore hardcode this address in your app?
This way a) you wouldn't need to worry about the user knowing any mail
information, and b) you could enable relaying.


So, from the last paragrah above, does this mean i could simply use our
own SMTP server, and send mails via that even though the users PC has no
settings or knowledge of the existence of our smtp server?

If this is so then it would definitely seem the best alternative

What if our SMTP server needs an user name and password, if I hard coded
it into my application could someone then hack the app and find our SMTP
server info? I have little experience in the SMTP/POP3 programming world
so these questions may be stupid...

Many thanks

Joe
Nov 17 '05 #8
Mark Rae wrote:
"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

The only thing I can guarantee is that the target machine that this app is
installed on will have a mail account.

Can you also guarantee that the target machine will have Internet accesss?
If so, why not abandon the email approach altogether and write a webservice
which the target machines will connect to?


Yes, they will have to have an internet connection on their machine as
part of the apps functionality is to connect to our hardware via an ADSL
link.

I'm not sure about the web service thing though, I have no real
experience with them so I'm not sure exactly what your suggesting? I
must admit though I wouldn't mind having a go with the web services.

Basically all I want to do is get information about plugin modules that
the user has installed on their machine, so that they can register these
modules to use them. I need to get the registration information from the
users machine to an email address on our mail server so that the people
generating the key codes to activate the modules can send an email back
to the user with the activation key.

I can't automate this via a web server app as I have been specifically
requested to perform the registration by email or phone.

Many thanks

Joe
Nov 17 '05 #9
You need to open up access to your SMTP server and essentially make it
public on the internet.

You could counteract the security issue by limiting its use to the IP
addresses of your clients, although this obviously has an admin overhead. If
you could do this though, it wouldn't matter if the SMTP server was
discovered by hacking your app. Chances are your server will be discovered
anyway.

"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
Adam Barker wrote:
I would've said it was far easier to use MailMessage than to start
checking for mail profiles. Outlook these days is quite locked down
security wise so I'm not sure how automatic you could make this. I would
almost definitely go for prompting for the smtp server.

Depending on the context on which you're developing this app, could you
not use your own SMTP server and therefore hardcode this address in your
app? This way a) you wouldn't need to worry about the user knowing any
mail information, and b) you could enable relaying.


So, from the last paragrah above, does this mean i could simply use our
own SMTP server, and send mails via that even though the users PC has no
settings or knowledge of the existence of our smtp server?

If this is so then it would definitely seem the best alternative

What if our SMTP server needs an user name and password, if I hard coded
it into my application could someone then hack the app and find our SMTP
server info? I have little experience in the SMTP/POP3 programming world
so these questions may be stupid...

Many thanks

Joe

Nov 17 '05 #10
Adam Barker wrote:
You need to open up access to your SMTP server and essentially make it
public on the internet.

You could counteract the security issue by limiting its use to the IP
addresses of your clients, although this obviously has an admin overhead. If
you could do this though, it wouldn't matter if the SMTP server was
discovered by hacking your app. Chances are your server will be discovered
anyway.


I'm Scared of that option.

I think I may just do as you suggested earlier and ask them for the SMTP
server information at initial start up. If they don't know it off hand
they will have to contact our customer support department who can guide
them through finding it.

Thanks a lot for your help Adam.

Joe
Nov 17 '05 #11
Don't use their e-mail client. Use yours.

Bring them to a web page where they enter the info that they need. That
info is e-mailed from your server to the address you have. The format is
fine.

If you need to validate, then have them enter their e-mail address on the
page. Then send them an e-mail with a link. The link will contain a URL
code referring to their particular registration record. They click the
link, and you know that they received the e-mail, so the e-mail address can
be reasonably assumed to belong to them.

Alternative: set up a web service on your web server, and have the app send
data to it.

Don't use System.Web.Mail in client code. That is a server-side option.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Joe_Black" <Jo******@newsgroups.nospam> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi all,

I have googled this and found some answers but none that give me exactly
what I'm after, maybe someone here can help.

I have an app that will be distributed to users for their laptop and home
PC's, I have no idea what operating system they are using although it will
be at least Win 98, I also have no idea what mail client they will be
using or which ISP their mail account is with. I would like to send an
email from the app using their default mail account, I had a look at the
System.Web.Mail classes, specifically MailMessage class, but this requires
a mail server, how would I get this information from the system? also it
requires a mail from field which I would like to get from the system
without asking the user to enter it, again how is this achieved?

Is there another way to do what I want to do, I know that there are the
Indy components but I'd rather avoid having to distibute more Dll's,
unless the Indy route is the best.

The only thing I can guarantee is that the target machine that this app is
installed on will have a mail account.

Many thanks

Joe

Nov 17 '05 #12
Just a reply to all you guys for your suggestions.

Many thanks

Joe
Nov 17 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dan glenn | last post by:
I'm creating HTML emails from a PHP site and sending them out to an email list (just about 40 people so far are on this list). I've tested and confirmed that these emails work in yahoo.com's...
10
by: Stuart Mueller | last post by:
I have an exchange server, that I sometimes use to perform mail shots to clients on our database, these can be upwards of 1000 at a time. As we don't want different clients to see who we are...
3
by: VB Programmer | last post by:
My company has it's own webserver, which is going to host our ASP.NET web application. We want the website to be able to send out emails. 1. What do I need on the server so that it has the...
2
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends -...
8
by: Philippe Lang | last post by:
Hello, I need to send emails from Postgresql triggers. I was able to do it with a 'plperlu' function, that calls the 'system' perl function, that itself calls the 'mail' shell function. Is...
3
by: Ant | last post by:
Hi, I'm using the MailMessage & smtpMail classes in System.Web.Mail to send mail, however it's not sending any emails. I'm using it on a Windows 2003 server. The simplest way to use this is...
8
by: windandwaves | last post by:
Hi Folk I want to send out a basic newsletter from my MySql database of contacts. Does anyone know a nice and simple bit of PHP that allows me to do this? TIA - Nicolas
5
by: Kun | last post by:
i have the following code: ---------------------------------- import smtplib from email.MIMEText import MIMEText fp = open('confirmation.txt', 'rb') msg = MIMEText(fp.read()) From =...
5
by: Jai | last post by:
Hi, I am in a problem of sending mass emails(newsletter) to my website members. Actually my problem is this: I want to send newsletter to my website members. But I had given a facility for...
2
by: lstanikmas | last post by:
Hi, I'm validating a form with this ASP but receiving some blank email responses; does anyone see anything wrong with it?: function isFormVarExcluded(thisForm, strToCheck) { var strExcludeVars...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.