18-10-16, 08:56 PM
السلام عليكم
لقد بحثت كثيرا عن كود لارسال بريد الكتروتي مع التعديل في الخط واللون
و اضافه صوره ك هيدر و ارسال الايميل من اليمين الي اليسار
و احببت مشاركته معكم للاستفادة
و اضافه صوره ك هيدر و ارسال الايميل من اليمين الي اليسار
و احببت مشاركته معكم للاستفادة
كود :
Private Sub send_email()
Dim mail As New MailMessage()
mail.From = New MailAddress("email@hotmail.com")
mail.To.Add("emailto@hotmail.com")
mail.Subject = "subject"
Dim plainView As AlternateView =
AlternateView.CreateAlternateViewFromString(
"<div style='direction:rtl'><span style=""font-weight: bold; padding-left: 20px;padding-right:5px""> yout'r txt <font color=""CORAL"">orange text</font> </span></div><br><br>" &
"<div style='direction:rtl'><span style=""font-weight: bold; padding-left: 20px;padding-right:5px""> you'r text <font color=""CORAL"">orangetext </font></span></div><br>",
Nothing, "text/plain")
'then we create the Html part
'to embed images, we need to use the prefix 'cid' in the img src value
'the cid value will map to the Content-Id of a Linked resource.
'thus <img src='cid:companylogo'> will map to a LinkedResource with a ContentId of 'companylogo'
Dim htmlView As AlternateView =
AlternateView.CreateAlternateViewFromString(
"<img style=""width:100%;"" src=cid:companylogo><br><br>" &
"<div style='direction:rtl'><span style=""font-weight: bold; padding-left: 20px;padding-right:5px""> any text you want <font color=""CORAL"">Read text</font> </span></div><br><br>" &
"<div style='direction:rtl'><span style=""font-weight: bold; padding-left: 20px;padding-right:5px""> any font <font color=""CORAL"">read text </font></span></div><br>", Nothing, "text/html")
Dim logo As New LinkedResource(My.Application.Info.DirectoryPath & "\logo.png", "image/jpeg")
logo.ContentId = "companylogo"
htmlView.LinkedResources.Add(logo)
mail.AlternateViews.Add(plainView)
mail.AlternateViews.Add(htmlView)
'Setup the Live host.
Dim smtp As New System.Net.Mail.SmtpClient("smtp.live.com", 587)
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("email@hotmail.com", "Password")
smtp.Send(mail)
End Sub