rjgagui
Member
- Joined
- Nov 5, 2014
- Messages
- 18
- Programming Experience
- Beginner
Hello guys, im sending email with a PDF attachment.
im using this code in sending excel files, my problem is when i use this code in sending PDF, it does not send consistently. example : i send email 1, it will be then received by the receipient, then send email 2, for some reason the email is not received but with no error on vb part or bounce message on email.. i dont know where is the problem.. please help me guys... (sorry for my bad english).
VB.NET:
Dim mail As New MailMessage()
Dim smtp As New SmtpClient()
Dim attach As Attachment
Try
If rbPdf.Checked = True Then
attach = New Attachment(pdfFile)
Else
attach = New Attachment(sourcepath)
End If
Dim mailto As String = "email@gmail.com"
mail.To.Add(mailto)
mail.From = New MailAddress("emailSender@some.com")
mail.Attachments.Add(New Attachment(pdfFile))
mail.IsBodyHtml = True
mail.Subject = "Transmittal Report"
mail.Body = Replace(txtEmailBody.Text, "imageName", If(UserID = 60 Or UserID = 61, "shiela", "marie"))
smtp.Host = "mail.some.com"
smtp.UseDefaultCredentials = False
smtp.Port = 26
'smtp.Port = 25
smtp.Credentials = New NetworkCredential("emailSender@some.com", "12345")
smtp.EnableSsl = False
smtp.Send(mail)
MsgBox("Email Sent.", vbInformation, "Transmittal Report")
attach.Dispose()
mail.Dispose()
smtp.Dispose()
im using this code in sending excel files, my problem is when i use this code in sending PDF, it does not send consistently. example : i send email 1, it will be then received by the receipient, then send email 2, for some reason the email is not received but with no error on vb part or bounce message on email.. i dont know where is the problem.. please help me guys... (sorry for my bad english).