Hi,
System.Web.Mail worked indeed fine for me! Thanks Terry!!
This is my class rroman:
Option Explicit On
Imports System.Web.Mail
Public Class clsMail
'These values are needed!!
Private pryFrom As String 'My Adress
Private prySmtpServer As String 'My SmtpServer
Public Sub New(ByVal strFrom As String, ByVal strSmtpServer As String)
pryFrom = strFrom
prySmtpServer = strSmtpServer
End Sub
Public Sub SendMail2(ByVal strTo As String, ByVal strSubject As String,
ByVal strMessage As String)
Dim oMail As New MailMessage
Try
With oMail
.From = pryFrom
.Subject = strSubject
.To = strTo
.Body = strMessage
End With
SmtpMail.SmtpServer = prySmtpServer
'send it:
SmtpMail.Send(oMail)
Catch ex As Exception
ErrorMessageSilent(Me, ex)
End Try
End Sub
"rr****@800mcmahan.com" <rr*****************@discussions.microsoft.com>
wrote in message news:03**********************************@microsof t.com...
I tried using the System.Web.Mail and added a reference to System.Web.dll
but it's not recognizing MailMessage or SmtpMail.
"Terry Olsen" wrote:
You might try using the System.Web.Mail namespace instead of Outlook.
You'll have to add a reference to System.Web.dll to access the
namespace.
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:eq**************@TK2MSFTNGP10.phx.gbl... Hi,
I need to send some emails in my Windows Service (VB.NET 2005). I made
for that a simple class, which works fine when I use it in a Windows Forms
application.
Although: When I put it in my Windows Service I got problems:
- I'm not able to let the Service send e-mails.
- When I let my service send an e-mail during the Starting or Stoping
of the
Service, it takes minutes before the Service is started or stopped
(and no e-mail is send).
Is there any particular reason for this? Can't Services send emails,
or what
am I possibly doing wrong?
Any help would be really appreciated!
thanks a lot in advance,
Pieter
The class I use for sending the mails is this:
Option Explicit On
Public Class clsMail
Public Sub SendMail(ByVal strTo As String, ByVal strSubject As
String, ByVal strMessage As String)
Dim Appl As Object
Dim out As Object
Try
Appl = CreateObject("Outlook.Application")
out = Appl.CreateItem(0)
With out
.Subject = strSubject
.To = strTo
.Body = strMessage
'Send it!
.Send()
End With
Catch ex As Exception
ErrorMessageSilent(Me, ex)
End Try
End Sub
End Class