Results 1 to 5 of 5

Thread: Multiple images in SMTP

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Multiple images in SMTP

    Hello

    I have this code to embed two images in a HTML email in my SMTP code:

    Code:
    Dim HtmlMessage As AlternateView = AlternateView.CreateAlternateViewFromString("<img src=cid:dimaHeader><br /><br /><img src=cid:Back2a><br /><br /><br /><body style='font-family......</body>", Nothing, "text/html")
                
    Dim Logo As New LinkedResource(Server.MapPath("~/Images/dimaHeader.jpg"), "image/jpeg") 'embedded image
    Logo.ContentId = "dimaHeader"
    HtmlMessage.LinkedResources.Add(Logo)
    
    Logo.ContentId = "Back2a"
    HtmlMessage.LinkedResources.Add(Logo)
    The first image, the banner (dimaHeader.jpg) appears in the email. but not the second image, Back2a.jpg (though I can see the image placeholder). That is because I haven't referenced Back2a.jpg (I think).

    How would I do that, please, given that I have already declared 'Logo'.

    Thank you.

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Multiple images in SMTP

    you reuse it...
    Code:
    Dim Logo As New LinkedResource(Server.MapPath("~/Images/dimaHeader.jpg"), "image/jpeg") 'embedded image
    Logo.ContentId = "dimaHeader"
    HtmlMessage.LinkedResources.Add(Logo)
    
    Logo = New LinkedResource(Server.MapPath("~/Images/Back2a.jpg"), "image/jpeg") 'embedded image
    Logo.ContentId = "Back2a"
    HtmlMessage.LinkedResources.Add(Logo)
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: Multiple images in SMTP

    That's just what the doctor ordered, tg - thank you again. Problem is that the image pushes the text to the bottom of the inbox window instead of the text appearing on top of the image. My email inbox now looks like this:

    Name:  tg.jpg
Views: 162
Size:  80.5 KB

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Multiple images in SMTP

    well, that's another issue... but if I had to guess, it depends on the HTMLBody ... my guess is the attachments are in line, and aren't being used as a background to anything.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: Multiple images in SMTP

    OK, I will do some research on it.

    It's not really an attachment though, is it, because it's embedded.

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width