hi I am trying to attach a PDF to a email message where the PDF is stored in a Sql table.
I have the following code be
i am trying to attach an PDF from a DB where that PDF is stored in SQL Database.
I am using the following code but nothing happens. I get no error, no email. It just to fail on the mailattachment call.
What is it that I am missing?
Dim attachmentebill As System.Net.Mail.Attachment
Try
attache = MailAttachment("filename.pdf", CType(emailOptionsRow.D_Attachment, Byte()))]If Not (attache Is Nothing) Then
email.Attachments.Add(attache)
End If
Catch ex As Exception
MsgBox(ex)
End Try
Public Function MailAttachment(ByVal AttachmentName As String, ByVal AttachmentByte As Byte()) As System.Net.Mail.Attachment
If AttachmentByte.Length <= 0 Then
Return Nothing
Else
Dim AttachmentStream As New System.IO.MemoryStream(AttachmentByte, 0, UBound(AttachmentByte))
Dim Attachment As New System.Net.Mail.Attachment(AttachmentStream, AttachmentName)
AttachmentStream.Close()
AttachmentStream.Dispose()
Return Attachment
End If
I have the following code be
i am trying to attach an PDF from a DB where that PDF is stored in SQL Database.
I am using the following code but nothing happens. I get no error, no email. It just to fail on the mailattachment call.
What is it that I am missing?
Dim attachmentebill As System.Net.Mail.Attachment
Try
attache = MailAttachment("filename.pdf", CType(emailOptionsRow.D_Attachment, Byte()))]If Not (attache Is Nothing) Then
email.Attachments.Add(attache)
End If
Catch ex As Exception
MsgBox(ex)
End Try
Public Function MailAttachment(ByVal AttachmentName As String, ByVal AttachmentByte As Byte()) As System.Net.Mail.Attachment
If AttachmentByte.Length <= 0 Then
Return Nothing
Else
Dim AttachmentStream As New System.IO.MemoryStream(AttachmentByte, 0, UBound(AttachmentByte))
Dim Attachment As New System.Net.Mail.Attachment(AttachmentStream, AttachmentName)
AttachmentStream.Close()
AttachmentStream.Dispose()
Return Attachment
End If