well i mention exchange explicitly cause i had some problems myself with it
some time ago
at the previous company i worked there was a Linux SMTP server wich worked
fine , in my new company we have exchange installed wich did not work with
the system.net.mail until someone in the groups told me that SMTP should be
activated on the exchange server in my case it wasn`t , and a quick talk to
the tech guy resolved my problem :-)
But it caused me a lot of frustration that i couldn`t get it to work in the
first case
"Michel Posseth [MCP]" <MS**@posseth.comschreef in bericht
news:e4**************@TK2MSFTNGP03.phx.gbl...
>
use the mail class , much easier and works from a service , web app ,
desktop app
You only need the values of a SMTP capable mail server in your network ,
in the case of an exchange server you must allow SMTP trafic and thus
connect through SMTP to the server instead of mapi .
regards
Michel
"AMP" <al***@penstonall.co.ukschreef in bericht
news:11*********************@q69g2000hsb.googlegro ups.com...
>>
I am trying to write a windows sevice that will send emails. The data
is stored in a database and the service scans the database for new
entries
It work well as a stardard windows app, but when you make is a service
it all works except it will not sent the emails
Attached is the public sub that should run, its the same code that in
the stardard winform, both app's are using Threads
Can anyone tell me whats wroung
Many thanks
Code VB.net 2005 with Outlook 2003
Public Sub mail2()
'Redemption is a separate package that needs to be install on any
machine running this program
Dim oApp As Outlook._Application = New Outlook.Application()
Dim oNS As Outlook._NameSpace = oApp.GetNamespace("mapi")
Dim oSyncs As Outlook.SyncObjects
Dim oSync As Outlook.SyncObject
Try
' Reference SyncObjects.
oSyncs = oNS.SyncObjects
oSync = oSyncs.Item("All Accounts")
' Create a new MailItem.
Dim oMsg
oMsg = CreateObject("Redemption.SafeMailItem")
oMsg.item = oApp.CreateItem(0)
oMsg.Subject = pvsubject
oMsg.Body = pvmessage & vbCr & vbCr
oMsg.To = pvsendto
' ' Add an attachment
Dim sSource As String = pvattachment
If pvattachment <"" Then
Dim oAttachs As Outlook.Attachments = oMsg.Attachments
Dim oAttach As Outlook.Attachment
oAttach = oAttachs.Add(sSource)
End If
' ' Send
oMsg.Send()
oSync.Start()
Catch ex As Exception
' Console.WriteLine(ex.Message)
' Me.EventLog.WriteEntry(ex.Message)
End Try
End sub