تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
send HTML body Email with image header
#1
السلام عليكم 

لقد بحثت كثيرا عن كود لارسال بريد الكتروتي مع التعديل في الخط واللون 
و اضافه صوره ك هيدر و ارسال الايميل من اليمين الي اليسار
 و احببت مشاركته معكم للاستفادة


كود :
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

الرد }}}
تم الشكر بواسطة: جميل علي , محمد سالم المحترف
#2
شكرا لك
ينقل للقسم المناسب
اللهم يا ارحم الراحمين ارحم اخي اباليث رحمة واسعة
 
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [VB.NET] عمل برنامج فحص الاميلات المتاحه في الهوتميل Check Email Hotmail Master Hacker 10 9,959 27-05-20, 11:18 PM
آخر رد: محمد ايمن

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم