By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

Send email with an attachment by smtp

P: 5
What is a exact option for Attachement on the sending mail with smtp.
I got an error : can't assign to read-only property
....
strPdffile = "H:\ARCTest\" & Pdffile
....
With iMsg
.Configuration = iCfg
'.Subject = "Example Subject"
.Subject = "FPB - CAD"
.To = "hng@faisalprivatebank.com"
.BCC = "mng@faisalprivatebank.com"
.Attachments.Add.filename = strPdffile
.TextBody = "With the complinents from FPB - CAD team"
.Send
End With



if I did :

.Attachments.Add(strPdffile)

I got the error : Type Mismatch

Someone may gift me an solution. Thank you in advanced.
Jan 29 '08 #1
Share this Question
Share on Google+
2 Replies


jamesd0142
100+
P: 469
i use this and it works fine:
Expand|Select|Wrap|Line Numbers
  1. Try
  2.  
  3.             Dim EMsg As New System.Net.Mail.MailMessage
  4.             EMsg.From = New System.Net.Mail.MailAddress("Fromaddress")
  5.             EMsg.To.Add("toaddress")
  6.             EMsg.Subject = "Test"
  7.             EMsg.Body = "Hello"
  8.             Dim smtp As New System.Net.Mail.SmtpClient("Server", port)
  9.             smtp.EnableSsl = True
  10.             If My.User.IsAuthenticated = True Then
  11.                 smtp.UseDefaultCredentials = False
  12.                 smtp.Credentials = New System.Net.NetworkCredential("login", "password")
  13.             End If
  14.  
  15.             '--------
  16.             Dim att As Attachment
  17.             att = New Attachment(Path & "MRF.zip")
  18.             EMsg.Attachments.Add(att)
  19.             '----------
  20.             smtp.Send(EMsg)
  21.             'MsgBox("Mail Sent")
  22.         Catch Send_Mail As Exception
  23.             MsgBox(Send_Mail.ToString)
  24.         End Try
  25.  
NOTE:
Most isp block you from sending emails from their smtp server using thirdparty apps... although google doesnt

smtp.gmail.com
port 587
Jan 29 '08 #2

P: 5
Thank you Jamesd0142,
but i have no vb.net .
Anywhere, I found for my solution.
The correct coding :
.....
.AddAttachment Path:\Filename
....
have a nice day
Jan 30 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.