eigenen Newsletterservice programmieren

06/06/2008 - 08:08 von Frank Salm | Report spam
Hallo,

wir wollen einen eigenen Newsletterservice anbieten. Von der
Geschàftsführung wird aber gewünscht, die Email Adressen nicht außer
Haus zu geben. Es ist ebenfalls gewünscht, dass die Mails über unseren
eigenen Exchange2000 Server zu versenden und eine eigene Software
dafür zu entwickeln.

Die Frage:
Über welche Schnittstelle von Excange-Server kann ich Emails
versenden?

Vielen Dank für Eure Hinweise.

Frank
 

Lesen sie die antworten

#1 Volker Strähle
06/06/2008 - 08:25 | Warnen spam
Wo kommen denn die Mail-Adressen her? Aus einer DB, dann bracuhst Du nur ein
ganz kleines .Net-Programm auf dem Server laufen lassen.

Imports System.Net.Mail

Imports System.Net.Mime

Public Class clsMail

Function sendMail(ByVal from As String, ByVal mailto As String, ByVal
mailsubject As String, ByVal mailbody As String, ByVal attachedfile As
String) As String

' Set mailServerName to be the name of the mail server

' you wish to use to deliver this message

Dim mailServerName As String = "192.168.100.1"

Try

' MailMessage is used to represent the e-mail being sent

Using message As New MailMessage(from, mailto, mailsubject, mailbody)

Dim data As Attachment

data = New Attachment(attachedfile, MediaTypeNames.Application.Octet)

Dim disposition As ContentDisposition = data.ContentDisposition

disposition.CreationDate = System.IO.File.GetCreationTime(attachedfile)

disposition.ModificationDate = System.IO.File.GetLastWriteTime(attachedfile)

disposition.ReadDate = System.IO.File.GetLastAccessTime(attachedfile)

message.Attachments.Add(data)

' SmtpClient is used to send the e-mail

Dim mailClient As New SmtpClient(mailServerName)

' UseDefaultCredentials tells the mail client to use the

' Windows credentials of the account (i.e. user account)

' being used to run the application

mailClient.UseDefaultCredentials = True

' Send delivers the message to the mail server

mailClient.Send(message)

End Using

Return "Message sent with Attachment."

Catch ex As FormatException

Return ex.Message

Catch ex As SmtpException

Return ex.Message

End Try

End Function

Function sendMail(ByVal from As String, ByVal mailto As String, ByVal
mailsubject As String, ByVal mailbody As String) As String

' Set mailServerName to be the name of the mail server

' you wish to use to deliver this message

Dim mailServerName As String = "192.168.100.1"

Try

' MailMessage is used to represent the e-mail being sent

Using message As New MailMessage(from, mailto, mailsubject, mailbody)

' SmtpClient is used to send the e-mail

Dim mailClient As New SmtpClient(mailServerName)

' UseDefaultCredentials tells the mail client to use the

' Windows credentials of the account (i.e. user account)

' being used to run the application

mailClient.UseDefaultCredentials = True

' Send delivers the message to the mail server

mailClient.Send(message)

End Using

Return "Message sent."

Catch ex As FormatException

Return ex.Message

Catch ex As SmtpException

Return ex.Message

End Try

End Function

End Class



Imports System.Net.Mail

Imports System.IO

Imports System

Module Main

Dim mailServerName As String = "localhost"

Dim fromAddress As String

Dim toAddress As String

Dim subject As String

Dim body As String

Enum MailMessagePart

ToAddress

FromAddress

Subject

Message

End Enum

Sub Main(ByVal args() As String)

LoadConfig()

Dim fehler As String = ""

Try

Dim newmail As New clsMail

If args.Length = 0 Then

fehler = newmail.sendmail(fromAddress, toAddress, subject, body)

Logdatei(fehler, toAddress)

Else

fehler = newmail.sendMail(fromAddress, toAddress, subject, body, args(0))

Logdatei(fehler, toAddress & " " & args(0))

End If

Catch ex As Exception

Logdatei("Fehler", ex.Message)

End Try

End Sub

Function LoadConfig() As Boolean

fromAddress = My.Settings.SMTPFromAddress

toAddress = My.Settings.SMTPToAddress

subject = My.Settings.SMTPSubject

body = My.Settings.SMTPBody

mailServerName = My.Settings.SMTPServer

End Function

Private Sub Logdatei(ByVal errtxt As String, ByVal errmsg As String)

Try

Dim sr As StreamWriter

Dim fl As String =
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location)
& "\errlog.txt"

If File.Exists(fl) = True Then

sr = File.AppendText(fl)

Else

sr = File.CreateText(fl)

End If

sr.WriteLine("-")

sr.WriteLine(System.Convert.ToString(Date.Now))

sr.WriteLine(errtxt)

sr.WriteLine(errmsg)

sr.Close()

Catch ex As Exception

End Try

End Sub

End Module



Das oben mußt Du nur noch mit Inhalt und Adressen aus Deiner DB füttern.



Volker





"Frank Salm" schrieb im Newsbeitrag
news:
Hallo,

wir wollen einen eigenen Newsletterservice anbieten. Von der
Geschàftsführung wird aber gewünscht, die Email Adressen nicht außer
Haus zu geben. Es ist ebenfalls gewünscht, dass die Mails über unseren
eigenen Exchange2000 Server zu versenden und eine eigene Software
dafür zu entwickeln.

Die Frage:
Über welche Schnittstelle von Excange-Server kann ich Emails
versenden?

Vielen Dank für Eure Hinweise.

Frank

Ähnliche fragen