We are using your Aspose.Network.Mail.SMTPClient to send messages and are encountering an issue where in certain environments the HTML body appears as an attachment on the email. We think the issue is only occuring when the message travels through an Exchange 2007 server but we aren’t sure. Our SMTPClient is pointing to an SMTP mail server. We are unable user authentication when using the SMTP client due to our architecture.
Are there any know setting requirements to have the SMTPClient work with Exchange or other mail servers?
Sample code follows:
Private Shared Sub SendEmail(ByVal sAddress As String, _
ByVal sDisplayName As String, _
ByVal sMessageSubject As String, _
ByVal sMessageBody As String, _
ByVal sMessageFooter As String, _
ByVal sOutputFormat As String, _
ByVal sBLOBFileNameToAttach As String, _
ByVal oFrom As Aspose.Network.Mail.MailAddress, _
ByVal oReplyTo As Aspose.Network.Mail.MailAddress, _
ByVal sJobID As String, _
ByVal oJoblet As JobMgmt.Joblet, _
ByVal oRecipient As JobMgmt.RecipientEMail)
Dim smtp As New Aspose.Network.Mail.SmtpClient
Dim message As New Aspose.Network.Mail.MailMessage
Dim sSMTPHost As String
Dim strmFile As IO.FileStream = Nothing
Try
smtp.Host = “MyServer.asi.corp”
smtp.DeliveryMethod = Aspose.Network.Mail.SmtpDeliveryMethod.Network
'Set the addresses
message.From = oFrom
message.ReplyTo = oReplyTo
message.To.Add(New Aspose.Network.Mail.MailAddress(sAddress, sDisplayName))
'Set the content
message.Subject = sMessageSubject
'Create the HTML view
Dim sbHtml As New Text.StringBuilder(1024)
sbHtml.Append("" & EscapeHtml(sMessageBody))
sbHtml.Append("
")
If Not String.IsNullOrEmpty(sMessageFooter) Then sbHtml.Append(EscapeHtml(sMessageFooter) & “
”)
sbHtml.Append(“Generated by Applied Systems Epic™
“)
sbHtml.AppendFormat(“Copyright {0:yyyy} Applied Systems, Inc. All rights reserved.”, DateTime.Now)
sbHtml.Append(”
”)
message.TextBody = sMessageBody
message.HtmlBody = sbHtml.ToString
'Add the file attachment (optional)
strmFile = New IO.FileStream(sBLOBFileNameToAttach, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Dim fileAttach As New Aspose.Network.Mail.Attachment(strmFile, _
String.Format(“Report{0:HHmmssff}{1}”, _
DateTime.Now, _
sOutputFormat)))
fileAttach.TransferEncoding = Aspose.Network.Mime.TransferEncoding.Base64
message.Attachments.Add(fileAttach)
'Send the message
Try
smtp.Send(message)
Catch ex As Exception
Throw New ApplicationException(“The ““Send”” operation failed for this e-mail address.”, ex)
End Try
Finally
If strmFile IsNot Nothing Then
strmFile.Close()
strmFile.Dispose()
strmFile = Nothing
End If
End Try
End Sub