Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Problem in sending mails with images ...

Problem in sending mails with images ...

Scheduled Pinned Locked Moved Visual Basic
helpquestioncsharphtmlcom
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nileshbahirshet
    wrote on last edited by
    #1

    please read carefully ... I have a Picture box on the form ... and I want to send that image with mail which appears in pictute box Now I have a code that takes the image from folder structure like c:\temp\aaa.jpg It sends image with mail PERFECTLY.... but now I have to send mail which is store in memory stream . not in file... I have code like How can I send the image wich stored in memory stream ??? I have code like Public sub senmail(ByVal image1 as Image) Dim subject As String = "Test EmbeddedImage" Dim contentId As String = "image1" Dim body As String = "Here is a picture of CRM: Dim ClientPC As New SmtpClient("ddd.com", 25) Dim Authentication As New Net.NetworkCredential("nmy@myserver.com", "password") ClientPC.Credentials = Authentication Dim mSender As New MailAddress("nmy@myserver.com") Dim mReceiver As New MailAddress("nmy@myserver.com") Dim sMail As New MailMessage(mSender, mReceiver) sMail.Subject = "Testing embedded image 25 july 3.41 PM" Dim av1 As AlternateView = AlternateView.CreateAlternateViewFromString(body, Nothing, MediaTypeNames.Text.Html) Dim ct, ct1 As New ContentType Dim ct2 As New ContentType("image") ct.MediaType = MediaTypeNames.Image.Jpeg Dim linkedResource1 As LinkedResource = New LinkedResource(ms, ct.MediaType) <----- gives error here linkedResource1.ContentId = contentId av1.LinkedResources.Add(linkedResource1) sMail.AlternateViews.Add(av1) sMail.IsBodyHtml = True ClientPC.Send(sMail) end sub

    C 1 Reply Last reply
    0
    • N nileshbahirshet

      please read carefully ... I have a Picture box on the form ... and I want to send that image with mail which appears in pictute box Now I have a code that takes the image from folder structure like c:\temp\aaa.jpg It sends image with mail PERFECTLY.... but now I have to send mail which is store in memory stream . not in file... I have code like How can I send the image wich stored in memory stream ??? I have code like Public sub senmail(ByVal image1 as Image) Dim subject As String = "Test EmbeddedImage" Dim contentId As String = "image1" Dim body As String = "Here is a picture of CRM: Dim ClientPC As New SmtpClient("ddd.com", 25) Dim Authentication As New Net.NetworkCredential("nmy@myserver.com", "password") ClientPC.Credentials = Authentication Dim mSender As New MailAddress("nmy@myserver.com") Dim mReceiver As New MailAddress("nmy@myserver.com") Dim sMail As New MailMessage(mSender, mReceiver) sMail.Subject = "Testing embedded image 25 july 3.41 PM" Dim av1 As AlternateView = AlternateView.CreateAlternateViewFromString(body, Nothing, MediaTypeNames.Text.Html) Dim ct, ct1 As New ContentType Dim ct2 As New ContentType("image") ct.MediaType = MediaTypeNames.Image.Jpeg Dim linkedResource1 As LinkedResource = New LinkedResource(ms, ct.MediaType) <----- gives error here linkedResource1.ContentId = contentId av1.LinkedResources.Add(linkedResource1) sMail.AlternateViews.Add(av1) sMail.IsBodyHtml = True ClientPC.Send(sMail) end sub

      C Offline
      C Offline
      ChandraRam
      wrote on last edited by
      #2

      nileshbahirshet wrote:

      Dim ct, ct1 As New ContentType

      Try this instead: Dim ct As New ContentType Dim ct1 As New ContentType IIRC, your way of definition means that ct is untyped in VB...

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups