473,657 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1491
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******@newsg roups.nospam> wrote in message
news:%2******** *******@TK2MSFT NGP12.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******@newsg roups.nospam> wrote in message
news:%2******** *******@TK2MSFT NGP12.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*****@ansmtps erver.com

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

Many thanks
Joe
Nov 17 '05 #3
I can't see how you could cope with all the different configurations without
programmaticall y 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******@newsg roups.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Adam Barker wrote:
I would build the SMTP server property as configurable in your
application.
"Joe_Black" <Jo******@newsg roups.nospam> wrote in message
news:%2******** *******@TK2MSFT NGP12.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*****@ansmtps erver.com

but the from address in the MailMessage object could be set to
re**********@ad omain.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
programmaticall y 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******@newsg roups.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP10.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******@newsg roups.nospam> wrote in message
news:uF******** ******@TK2MSFTN GP09.phx.gbl...
Adam Barker wrote:
I can't see how you could cope with all the different configurations
without programmaticall y 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******@newsg roups.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP10.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******@newsg roups.nospam> wrote in message
news:%2******** *******@TK2MSFT NGP12.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******@newsg roups.nospam> wrote in message
news:%2******** *******@TK2MSFT NGP12.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******@newsg roups.nospam> wrote in message
news:uG******** ******@TK2MSFTN GP12.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

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

Similar topics

1
2883
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 webmail. And I know they work on *my* Outlook Express. But I have one person (I know of) who gets the emails as plain text, so she sees the HTML code for the email instead of its proper representation. She has, like myself, OE6, and other html emails...
10
4967
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 working with we put these mailshots in the bcc field of the mails. This can sometimes cause a problem as we are getting alot of mails bounced back. I would like to write a script to have these emails sent out individually using the to: field of the...
3
2221
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 abillity to send out emails? It is a Windows 2000 Professional SP3 server. 2. Any examples (code, etc...) on how to send out emails via an ASP.NET webform? Thanks!
2
9225
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 - I see hebrew, it is just sending by myself using *.aspx scripts). In web.config I have the following : <configuration> <system.web>
8
1962
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 is safe to do things like this? Is there a possible concurrent access that could arise?
3
3610
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 smtpMail.Send("from@here.com", to@there.com, "Message subject", "Message Body") I'm sending it to my own email address on a different server using a dummy
8
1759
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
23796
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 = 'xxxx@xxxx.xxxx.edu'
5
2437
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 each member to choose different category of products or all products newsletter.
2
3749
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 = thisForm.elements.value; var arrExcludeVars = strExcludeVars.split(","); for (var j=0; j<arrExcludeVars.length; j++) { if (arrExcludeVars == strToCheck) return true;
0
8411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.