We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML body appears as attachment

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

Hi,

1. Could you please save the MailMessage to local file, and send me for reviewing? You can call the MailMessage.Save(string filename) to get the eml file.

2. Are you useing the exchange 2007 as your smtp server? It only happens on Exchange 2007?

3. What's your .net framework version? .net 2.0 or .net 3.5? 64 bit OS or 32 bit OS?

Thanks,

1. Could you please save the MailMessage to local file, and send me for reviewing? You can call the MailMessage.Save(string filename) to get the eml file.

--See Attached

2. Are you useing the exchange 2007 as your smtp server? It only happens on Exchange 2007?

--The code is calling into an SMTP Server directly. We have tested going through the SMTP server directly to our email and through the SMTP first followed by the Exchange 2007 server. When we only go through the SMTP server the email looks normal. We are trying to set up additional test environments to check other mail servers

3. What's your .net framework version? .net 2.0 or .net 3.5? 64 bit OS or 32 bit OS?

-- The issue is happening on a 64 bit Windows Server 2008 machine. Our code is written in VB .Net 3.5

I have a little more data on the issue.

This is only happening on our 64 bit servers. Our 32 bit servers seem to be working properly. The 64 bit servers are using Aspose.Network vs 4.7.0.8 (.NET 3.5) because this is the last 64 bit version of the assembly that we know of. The 32 bit servers are using Aspose.Network vs 4.8.0.5 (.NET 3.5).

Hello,

Can you try the latest hotfix v4.8.1?

Thanks,

That seems to work. Thanks!