Best way to send e-mail 
Author Message
 Best way to send e-mail

I have found the e-mail objects in .NET, but it seems like they require Outlook or Outlook express in order to send mail. Is there an alternative, or a reliable way to send e-mail without user interaction?

I'm trying to send mail from server app when errors occure.

TIA
Jeremy



Thu, 22 Sep 2005 09:34:56 GMT  
 Best way to send e-mail


Quote:
>> I have found the e-mail objects in .NET, but it seems like they require
Outlook or Outlook
>> express in order to send mail. Is there an alternative, or a reliable way
to send e-mail
>> without user interaction?

    Private sendMail()
        Dim mm As New MailMessage()



        mm.Subject = "Test VB.NET Mail"
        mm.Body = "This is a test at " + Now

        'optional stuff



        SmtpMail.SmtpServer = "mail.someServer.com"
        SmtpMail.Send(mm)
    End Sub



Thu, 22 Sep 2005 09:54:39 GMT  
 Best way to send e-mail

Quote:

>>> I have found the e-mail objects in .NET, but it seems like they require
> Outlook or Outlook
>>> express in order to send mail. Is there an alternative, or a reliable
>>> way
> to send e-mail
>>> without user interaction?

> Private sendMail()
> Dim mm As New MailMessage()



> mm.Subject = "Test VB.NET Mail"
> mm.Body = "This is a test at " + Now

> 'optional stuff



> SmtpMail.SmtpServer = "mail.someServer.com"
> SmtpMail.Send(mm)
> End Sub

This does require that some version of CDO exist on the machine.  Most
people pick up CDO by having Outlook on their machines, but it's part of
Win2K and WinXP.  I am sure there are places on Microsoft's site where it
can be downloaded as well.  Go there and search for CDO or "Collaborative
Data Objects"

                        -chris

--
Chris J. Breisch, MCSD.NET, MCDBA



Thu, 22 Sep 2005 10:06:30 GMT  
 Best way to send e-mail
Liz,

What happens if CDO is not available?

Quote:



> >> I have found the e-mail objects in .NET, but it seems like they require
> Outlook or Outlook
> >> express in order to send mail. Is there an alternative, or a reliable way
> to send e-mail
> >> without user interaction?

>     Private sendMail()
>         Dim mm As New MailMessage()



>         mm.Subject = "Test VB.NET Mail"
>         mm.Body = "This is a test at " + Now

>         'optional stuff



>         SmtpMail.SmtpServer = "mail.someServer.com"
>         SmtpMail.Send(mm)
>     End Sub



Thu, 22 Sep 2005 10:08:13 GMT  
 Best way to send e-mail
Thx


Quote:

> >>> I have found the e-mail objects in .NET, but it seems like they require
> > Outlook or Outlook
> >>> express in order to send mail. Is there an alternative, or a reliable
> >>> way
> > to send e-mail
> >>> without user interaction?

> > Private sendMail()
> > Dim mm As New MailMessage()



> > mm.Subject = "Test VB.NET Mail"
> > mm.Body = "This is a test at " + Now

> > 'optional stuff



> > SmtpMail.SmtpServer = "mail.someServer.com"
> > SmtpMail.Send(mm)
> > End Sub

> This does require that some version of CDO exist on the machine.  Most
> people pick up CDO by having Outlook on their machines, but it's part of
> Win2K and WinXP.  I am sure there are places on Microsoft's site where it
> can be downloaded as well.  Go there and search for CDO or "Collaborative
> Data Objects"

> -chris

> --
> Chris J. Breisch, MCSD.NET, MCDBA



Thu, 22 Sep 2005 10:08:52 GMT  
 Best way to send e-mail

Quote:

> Liz,

> What happens if CDO is not available?





>> >> I have found the e-mail objects in .NET, but it seems like they
>> require
>> Outlook or Outlook
>> >> express in order to send mail. Is there an alternative, or a reliable
>> way
>> to send e-mail
>> >> without user interaction?

>> Private sendMail()
>> Dim mm As New MailMessage()



>> mm.Subject = "Test VB.NET Mail"
>> mm.Body = "This is a test at " + Now

>> 'optional stuff



>> SmtpMail.SmtpServer = "mail.someServer.com"
>> SmtpMail.Send(mm)
>> End Sub

You'll get a COM error trying to instantiate the CDO object.

                        -chris

--
Chris J. Breisch, MCSD.NET, MCDBA



Thu, 22 Sep 2005 10:17:14 GMT  
 Best way to send e-mail


Quote:
>> What happens if CDO is not available?

I gather your mail does not get sent with the code I posted ... sorry,
apparently I assumed too much about your config ....


Quote:



> >> I have found the e-mail objects in .NET, but it seems like they require
> Outlook or Outlook
> >> express in order to send mail. Is there an alternative, or a reliable
way
> to send e-mail
> >> without user interaction?

>     Private sendMail()
>         Dim mm As New MailMessage()



>         mm.Subject = "Test VB.NET Mail"
>         mm.Body = "This is a test at " + Now

>         'optional stuff



>         SmtpMail.SmtpServer = "mail.someServer.com"
>         SmtpMail.Send(mm)
>     End Sub



Thu, 22 Sep 2005 10:30:54 GMT  
 Best way to send e-mail
I am running XP pro, I assume CDO is installed, but mail does not get sent. The object in your code was the same one I was referring to in my orriginal post. I am looking for an alternative.

<flame>
I don't want to use CDO, I think it's lame that you need this component for a protocol that is standardized (SMTP), and is implied to be implemented by the name of the object (SmtpMail). Furthermore, I *think* that CDO has been incorporated as the interface to Que mail to your NT/2k server, but this also is dumb, because it should be part of a seperate set of collorabation objects. IMO.
</flame>

Jeremy

Quote:



> >> What happens if CDO is not available?

> I gather your mail does not get sent with the code I posted ... sorry,
> apparently I assumed too much about your config ....





> > >> I have found the e-mail objects in .NET, but it seems like they require
> > Outlook or Outlook
> > >> express in order to send mail. Is there an alternative, or a reliable
> way
> > to send e-mail
> > >> without user interaction?

> >     Private sendMail()
> >         Dim mm As New MailMessage()



> >         mm.Subject = "Test VB.NET Mail"
> >         mm.Body = "This is a test at " + Now

> >         'optional stuff



> >         SmtpMail.SmtpServer = "mail.someServer.com"
> >         SmtpMail.Send(mm)
> >     End Sub



Thu, 22 Sep 2005 11:00:14 GMT  
 Best way to send e-mail
And why does it use COM interop?! This is almost as ridiculous as the VisualStudio DTE (VS AddIns) extensions running off COM.

Ok, we have an entirely new system, but the most of the important stuff we're just going to bolt on over top of our old system that was totally bug prone (arguably) so we can save a little development time... it drives me crazy.

I am running XP pro, I assume CDO is installed, but mail does not get sent. The object in your code was the same one I was referring to in my orriginal post. I am looking for an alternative.

<flame>
I don't want to use CDO, I think it's lame that you need this component for a protocol that is standardized (SMTP), and is implied to be implemented by the name of the object (SmtpMail). Furthermore, I *think* that CDO has been incorporated as the interface to Que mail to your NT/2k server, but this also is dumb, because it should be part of a seperate set of collorabation objects. IMO.
</flame>

Jeremy

Quote:



> >> What happens if CDO is not available?

> I gather your mail does not get sent with the code I posted ... sorry,
> apparently I assumed too much about your config ....





> > >> I have found the e-mail objects in .NET, but it seems like they require
> > Outlook or Outlook
> > >> express in order to send mail. Is there an alternative, or a reliable
> way
> > to send e-mail
> > >> without user interaction?

> >     Private sendMail()
> >         Dim mm As New MailMessage()



> >         mm.Subject = "Test VB.NET Mail"
> >         mm.Body = "This is a test at " + Now

> >         'optional stuff



> >         SmtpMail.SmtpServer = "mail.someServer.com"
> >         SmtpMail.Send(mm)
> >     End Sub



Thu, 22 Sep 2005 11:08:40 GMT  
 Best way to send e-mail

Quote:

> I am running XP pro, I assume CDO is installed, but mail does not get
> sent. The object in your code was the same one I was referring to in my
> orriginal post. I am looking for an alternative.

> <flame>
> I don't want to use CDO, I think it's lame that you need this component
> for a protocol that is standardized (SMTP), and is implied to be
> implemented by the name of the object (SmtpMail). Furthermore, I *think*
> that CDO has been incorporated as the interface to Que mail to your NT/2k
> server, but this also is dumb, because it should be part of a seperate
> set of collorabation objects. IMO.
> </flame>

Turn off the fire.

The non-Exchange versions of CDO don't have anything in them other than
what you need for SMTP.  It's a reasonable solution.  Would you want to
have to write two different versions of your code depending on whether the
person had an Exchange client installed on their machine?

So, there's really no reason to not "want to use CDO".  By saying that,
you're essentially saying "I don't want to use SMTP".

What kind of message do you get when your mail doesn't get sent?

If you want an alternative, I believe there are several at codeproject.com.

                                -chris
--
Chris J. Breisch, MCSD.NET, MCDBA



Thu, 22 Sep 2005 11:08:55 GMT  
 Best way to send e-mail
Ok, I just read the overview of CDO, and I see that you are right, but why is it still running off COM under .NET?


Quote:

> > I am running XP pro, I assume CDO is installed, but mail does not get
> > sent. The object in your code was the same one I was referring to in my
> > orriginal post. I am looking for an alternative.

> > <flame>
> > I don't want to use CDO, I think it's lame that you need this component
> > for a protocol that is standardized (SMTP), and is implied to be
> > implemented by the name of the object (SmtpMail). Furthermore, I *think*
> > that CDO has been incorporated as the interface to Que mail to your NT/2k
> > server, but this also is dumb, because it should be part of a seperate
> > set of collorabation objects. IMO.
> > </flame>

> Turn off the fire.

> The non-Exchange versions of CDO don't have anything in them other than
> what you need for SMTP.  It's a reasonable solution.  Would you want to
> have to write two different versions of your code depending on whether the
> person had an Exchange client installed on their machine?

> So, there's really no reason to not "want to use CDO".  By saying that,
> you're essentially saying "I don't want to use SMTP".

> What kind of message do you get when your mail doesn't get sent?

> If you want an alternative, I believe there are several at codeproject.com.

> -chris
> --
> Chris J. Breisch, MCSD.NET, MCDBA



Thu, 22 Sep 2005 11:33:33 GMT  
 Best way to send e-mail


Quote:
>> I am running XP pro, I assume CDO is installed, but mail does not get

sent. The object in your
Quote:
>> code was the same one I was referring to in my orriginal post. I am

looking for an alternative.

If you don't want to use CDO, then why the question ?  Open a socket and
talk to your SMTP server ... I had the same problem (on XP, with Outlook
installed) with mail not being sent until I set the Smtp.SmtpServer property
explicitly;  did you actually try the code ?

FWIW, I tend to agree with you about the stupid CDOSYS dependency, btw ...

<flame>
I don't want to use CDO, I think it's lame that you need this component for
a protocol that is standardized (SMTP), and is implied to be implemented by
the name of the object (SmtpMail). Furthermore, I *think* that CDO has been
incorporated as the interface to Que mail to your NT/2k server, but this
also is dumb, because it should be part of a seperate set of collorabation
objects. IMO.
</flame>

Jeremy


Quote:



> >> What happens if CDO is not available?

> I gather your mail does not get sent with the code I posted ... sorry,
> apparently I assumed too much about your config ....





> > >> I have found the e-mail objects in .NET, but it seems like they
require
> > Outlook or Outlook
> > >> express in order to send mail. Is there an alternative, or a reliable
> way
> > to send e-mail
> > >> without user interaction?

> >     Private sendMail()
> >         Dim mm As New MailMessage()



> >         mm.Subject = "Test VB.NET Mail"
> >         mm.Body = "This is a test at " + Now

> >         'optional stuff



> >         SmtpMail.SmtpServer = "mail.someServer.com"
> >         SmtpMail.Send(mm)
> >     End Sub



Thu, 22 Sep 2005 11:38:50 GMT  
 Best way to send e-mail

Quote:

> Ok, I just read the overview of CDO, and I see that you are right, but
> why is it still running off COM under .NET?

I don't have an answer for that, other than Microsoft obviously didn't want
to reimplement it.  I'm not sure why...SMTP isn't that hard to implement.  
But, maybe they felt it was rock solid and it would be a waste of time.  
Besides, everything that accesses the system eventually goes to COM or
P/Invoke.  So, it's really just a question of at what level in the code it
does so.

                        -chris

--
Chris J. Breisch, MCSD.NET, MCDBA



Thu, 22 Sep 2005 20:34:48 GMT  
 Best way to send e-mail

Quote:



>>> I am running XP pro, I assume CDO is installed, but mail does not get
> sent. The object in your
>>> code was the same one I was referring to in my orriginal post. I am
> looking for an alternative.

> If you don't want to use CDO, then why the question ?  Open a socket and
> talk to your SMTP server ... I had the same problem (on XP, with Outlook
> installed) with mail not being sent until I set the Smtp.SmtpServer
> property
> explicitly;  did you actually try the code ?

> FWIW, I tend to agree with you about the stupid CDOSYS dependency, btw
> ...

I don't have a problem with the dependency itself.  I DO have a problem
with the fact that there's a dependency in the Framework that's not
installed as part of the framework and not guaranteed to be on the machine.
 I also have a problem that MailMessage pretends to give you full access to
the headers and doesn't really.  Some of the headers it sets itself and
there's no way to override.  Try to send a message that's not "text/plain",
"text/multipart-alternative" or "text/html" for example.  You can't.  But
the RFC allows for several other content types.

As I said, though, there are several good SMTP implementations at
www.codeproject.com.
--
Chris J. Breisch, MCSD.NET, MCDBA



Thu, 22 Sep 2005 20:40:11 GMT  
 Best way to send e-mail
Jeremy,
A while ago I wrote a component that used winsock and communicated with the
SMTP server directly.  I was able to get it to send emails to my hotmail
account, but when trying to email a text message to my phone (which is what
I needed) it always failed.  The way I accomplished this was by sending an
email through outlook, and watching the network activity with a packet
sniffer.  If you do this, be sure to set the emails format to plain text
(not html) as it is much easier to understand how it is being sent.  I
appologize, I do not have this component anymore, I got rid of it because it
didn't do what I needed.  I ended up using ASPEmail, and sending emails via
POST to an ASP web page.  Hope this helps,

Chris LaJoie



Fri, 23 Sep 2005 01:42:47 GMT  
 
 [ 18 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Best way to send an email from Windows form

2. Send Mail Without Leaving Message in Sent Mail

3. VBA code to send an email message through Lotus Notes mail interface

4. Email sent from another mail account

5. Send email to a mailing list

6. Automating sending mail using email adress from file

7. Sending mail via alternate email account

8. sorting sent mail by email account in Outlook 2K

9. send email using system.web.mail

10. Sending mail without using any email client !

11. Sending mail without using any email client !

12. Sending mail without using any email client !

 

 
Powered by phpBB® Forum Software