I am sending my Mails in my own Thread Class, using the following “run” code:
[code]RunningThreads.Increase
If Self.tempOTRS = Nil Then Self.tempOTRS = New OTRSDatenbank.OTRSConnection
Try
Dim uid As New UUIDMBS
MessageID = uid.ValueHexString
Dim e As New CURLEmailMBS
e.SetFrom “kundensupport@XXXXXX.net”, “XXXXXX Kundensupport”
// e.Subject = EncodeEmailSubjectMBS( Betreff )
e.Subject = Betreff
e.AddHeader “Mime-Version: 1.0”
e.AddHeader "X-Mailer: XXXXXX System Mailer " + WAG5Versionsnummer( True )
e.AddReplyTo “kundensupport@XXXXXX.net”, “XXXXXX Kundensupport”
e.AddHeader “Message-ID: <” + MessageID + “@ticket.XXXXXX.ag>”
// e.SMTPPassword = “xxx”
// e.SMTPUsername = “xxxxxx”
e.SetServer “smtp://” + KundensupportMail_ServerAdress, False
Dim Empfaenger( -1 ) As String = Receipient.Split( “,” )
If UBound( Empfaenger ) > 0 Then
While UBound( Empfaenger ) > 0
If Empfaenger( UBound( Empfaenger ) ).Left( 2 ) = "C:" Then
e.AddCC Empfaenger( UBound( Empfaenger ) ).Replace( "C:", "" ), Empfaenger( UBound( Empfaenger ) ).Replace( "C:", "" )
ElseIf Empfaenger( UBound( Empfaenger ) ).Left( 2 ) = "B:" Then
e.AddBCC Empfaenger( UBound( Empfaenger ) ).Replace( "B:", "" ), Empfaenger( UBound( Empfaenger ) ).Replace( "B:", "" )
Else
e.AddTo Empfaenger( UBound( Empfaenger ) ), Empfaenger( UBound( Empfaenger ) )
End If
Empfaenger.Remove( UBound( Empfaenger ) )
Wend
// Element 0 des Array, wird immer als To gesendet
e.AddTo Empfaenger( UBound( Empfaenger ) ).Replace( "C:", "" ).Replace( "B:", "" ), Empfaenger( UBound( Empfaenger ) ).Replace( "C:", "" ).Replace( "B:", "" )
Else
e.AddTo Empfaenger( 0 ), Empfaenger( 0 )
End If
e.PlainText = PlainTextBody
e.HTMLText = PlainTextBody.PlainTextToHTML
For Each Anhang As FolderItem In Attachments
Dim b As BinaryStream = BinaryStream.Open(Anhang, False)
Dim mb as MemoryBlock = b.read(b.length)
e.AddAttachment mb, EncodingToISO8859MBS(Anhang.Name), “”
Next
dim c as new CURLSMBS
If c.SetupEmail(e) Then
dim er as integer = c.PerformMT
if er <> 0 then
Fehler = "Fehler Nummer " + Str(er) + " ist aufgetreten. Die Mail konnte nicht versendet werden!"
Else
If CDbl(OTRSTicketID) > 0 Then
// Ticket Eintrag
AnhaengeInfoFuerLog = ""
If Attachments.Ubound > -1 Then
AnhaengeInfoFuerLog = "Anhnge:"
For Anhang As Integer = 0 To Attachments.Ubound
AnhaengeInfoFuerLog = AnhaengeInfoFuerLog + EndOfLine + Attachments(Anhang).Name
Next
PlainTextBody = PlainTextBody + EndOfLine + EndOfLine + AnhaengeInfoFuerLog
End If
If AddMailToOTRSTicket(OTRSTicketID, PlainTextBody, Receipient, MessageID, Betreff) Then
End If
// Ticket Status
If TicketStatus > 0 Then
If Not OTRS_UpdateTicketStatus(OTRSTicketID, Str(TicketStatus), self.tempOTRS) Then
End If
End If
End If
End If
Display_Notification(True)
Else
Display_Notification(False)
End If
Catch e As UnsupportedFormatException
self.Fehler = “Die Email Adresse des Empfngers ist fehlerhaft!”
Display_Notification(False)
End Try
RunningThreads.Decrease[/code]