D
DraguVaso
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
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