Hi I have a windows service which needs to send an email every couple of hours if a variable becomes true.
I tested my code in a windows form and the same code does nothing in the windows service.
here's what I have:
Nothing happens... no email no error nothing...
Is there anything I can do here? Is it a permissions thing? I've gve the service a number of different users but nothing has worked.
Please help,
TIA
Bill
I tested my code in a windows form and the same code does nothing in the windows service.
here's what I have:
VB.NET:
Imports System.Net.Mail
Public Sub SendSMTP(ByVal strFromAddress As String, ByVal strFromName As String, ByVal strToAddress As String, ByVal strToName As String,
ByVal strReplyToAddrr As String, ByVal strReplyToName As String, ByVal strSubject As String, ByVal strBody As String, ByVal strCC As String, ByVal strAttachments As String)
Dim insMail As New MailMessage(New MailAddress(strFromAddress, strFromName), New MailAddress(strToAddress, strToName))
With insMail
.Subject = strSubject
.Body = strBody
.ReplyTo = New MailAddress(strReplyToAddrr, strReplyToName)
.IsBodyHtml = True
If Not strAttachments.Equals(String.Empty) Then
Dim strFile As String
Dim strAttach() As String = strAttachments.Split(";")
For Each strFile In strAttach
.Attachments.Add(New Attachment(strFile.Trim()))
Next
End If
End With
Dim smtp As New System.Net.Mail.SmtpClient
smtp.UseDefaultCredentials = False
smtp.Credentials = New System.Net.NetworkCredential(My.Settings.fromAddress, My.Settings.mailPassword)
smtp.Host = My.Settings.SMTPServer
smtp.Port = 25
smtp.Send(insMail)
End Sub
Nothing happens... no email no error nothing...
Is there anything I can do here? Is it a permissions thing? I've gve the service a number of different users but nothing has worked.
Please help,
TIA
Bill