Hi,
I have an error everything the "client.send" functionality is call and the error has no message.
Please take a look of the function below and could you tell me what I do wrong?
Public Shared Sub SendMail(ByVal docContent As Byte(), ByVal imagePath As String, ByVal fromEmail As String, ByVal toEmail As String, ByVal ccEmail As String, ByVal bccEmail As String, ByVal subjectText As String)
Try
Dim licenseDoc As Aspose.Words.License
Dim licenseNetwork As Aspose.Network.License
licenseDoc = New Aspose.Words.License
licenseDoc.SetLicense(imagePath & "\Aspose.Total.lic")
licenseNetwork = New Aspose.Network.License
licenseNetwork.SetLicense(imagePath & "\Aspose.Total.lic")
Dim docDocument As Document
'save html to stream and images to folder
Dim stream As MemoryStream = New MemoryStream()
docDocument = GetDocument(docContent)
docDocument.SaveOptions.ExportImagesFolder = imagePath & "\WordDocs"
docDocument.Save(stream, SaveFormat.Html)
'get html code from stream
stream.Position = 0
Dim reader As StreamReader = New StreamReader(stream)
Dim htmlBody As String = reader.ReadToEnd()
Dim msg As Mail.MailMessage = New Mail.MailMessage(fromEmail, toEmail)
'add embedded images
Dim imageNames As String() = Directory.GetFiles(imagePath)
Dim i As Integer = 0
Dim j As Integer = 0
For i = 0 To (imageNames.Length - 1)
htmlBody = htmlBody.Replace(imageNames(i), "cid:" + Path.GetFileNameWithoutExtension(imageNames(i)))
Dim image As Mail.LinkedResource = New Mail.LinkedResource(imageNames(i), Mime.MediaTypeNames.Image.Jpeg)
image.ContentId = Path.GetFileNameWithoutExtension(imageNames(i))
msg.LinkedResources.Add(image)
Next
'send mail
'msg.To.Add(toEmail)
If ccEmail <> "" Then msg.CC.Add(ccEmail)
If bccEmail <> "" Then msg.Bcc.Add(bccEmail)
msg.HtmlBody = htmlBody
msg.Subject = subjectText
Dim client As Mail.SmtpClient = New Mail.SmtpClient(GetConfigValue("SmtpServer")) ' "Host", "Username", "password")
client.Send(msg)
'remove images
For j = 0 To (imageNames.Length - 1)
File.Delete(imageNames(i))
Next
licenseDoc = Nothing
licenseNetwork = Nothing
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
_________________________________________________________________
Thanks,
Tan Quan