Results 1 to 14 of 14

Thread: VB6 - EMail - JPEG IMAGE

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    48

    Smile VB6 - EMail - JPEG IMAGE

    Hi,
    I want to send the picture box image embedded as body of email. So i converted it to Jpeg image and wrote HTML code for image. But the recipient is not getting the image embedded. Can anyone help me with this??

    Here is my code:



    Option Explicit
    Private Sub Form_Load()
    Picture1.AutoRedraw = True
    Dim w As Double
    Dim x As Double
    Dim y As Double
    Dim z As Double
    Dim z1 As Double

    w = 650
    x = 301
    y = 39
    z = 109
    z1 = 201

    Dim xx As Double
    Dim yy As Double
    Dim zz As Double
    Dim uu As Double

    If w = 0 Then MsgBox "There are no records for" & DateTime.Date & "to be displayed"
    If w > 0 Then
    xx = (x * 100) / w
    yy = xx + (y * 100) / w
    zz = yy + (z * 100) / w
    uu = zz + (z1 * 100) / w
    Call DrawPiePiece(QBColor(1), 0.001, xx)
    Call DrawPiePiece(QBColor(6), xx, yy)
    Call DrawPiePiece(QBColor(3), yy, zz)
    Call DrawPiePiece(QBColor(5), zz, uu)
    End If

    SavePicture Picture1.Image, "C:\TITAN\imagefile.jpeg"

    Dim oApp As Outlook.Application
    Dim oEmail As MailItem
    Dim colAttach As Outlook.Attachments
    Dim oAttach As Outlook.Attachment


    Set oApp = CreateObject("Outlook.Application")
    Set oEmail = oApp.CreateItem(olMailItem)
    Set colAttach = oEmail.Attachments

    With oEmail
    .To = "[email protected]"
    .Subject = "DAILY REPORT"
    .BodyFormat = olFormatHTML
    .HTMLBody = "<HTML><BODY><img src='cid:C:\TITAN\imagefile.jpeg'></img></BODY></HTML>"
    .Save
    .Display
    .Send
    End With
    Set oEmail = Nothing
    Set colAttach = Nothing
    Set oAttach = Nothing
    Set oApp = Nothing

    End Sub

    Public Sub DrawPiePiece(lColor As Long, ByVal fStart As Double, ByVal fEnd As Double)
    Const PI As Double = 3.14159265359
    Const CircleEnd As Double = -2 * PI
    Dim dStart As Double
    Dim dEnd As Double

    Picture1.FillColor = lColor
    Picture1.FillStyle = 0
    dStart = fStart * (CircleEnd / 100)
    dEnd = fEnd * (CircleEnd / 100)
    Picture1.Circle (170, 150), 100, , dStart, dEnd
    End Sub

  2. #2
    Addicted Member
    Join Date
    Sep 2009
    Posts
    190

    Re: VB6 - EMail - JPEG IMAGE

    I don't think you can do that.
    Because image in not part of your html file. It is just linked.

    Options:
    -chose other kind of file which allow embedding images like pdf, mht, cdr or else.
    -send only a image (you can get text in image with same picture box too).
    -send html+linked image as compressed archive so recipient can get your files situation. That can be done with some kind of archiver, zip, rar, 7z or manually.

    I think so because I tryed this

  3. #3
    Addicted Member
    Join Date
    Jul 2007
    Posts
    228

    Re: VB6 - EMail - JPEG IMAGE

    Try this html code putting the correct width and height pixels for your image. No guarantees but worth a shot.

    <img src="file:///C:\TITAN\imagefile.jpeg" width="270" height="39" style="border: 0pt none;margin:0pt 0pt 0pt 0pt;" title="imagefile.jpeg" alt="[image]" />

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: VB6 - EMail - JPEG IMAGE

    1. You are not saving the image as jpg. Using SavePicture will save it in bitmap format but with a jpeg extension. You need GDI+ or other DLLs to save to jpg format as VB can't do it by itself.
    2. Are you getting any errors?

    I think nime was right on and maybe Tom Moran's reply will fix it.

    If not... I am guessing 4 things at the moment, either 1) the image was not saved correctly or 2) if outlook uses extensions to validate image then you may want to opt for jpg vs. jpeg, or 3) the image is not jpg format but bmp format with a jpeg extension & outlook may think it is an invalid image, 4) the image does not exist where you expected it

    Also note that for testing you should probably be sending yourself emails vs. some recipient. This way you can make sure it works beforehand.

    Edited: Not an outlook user myself for the most part. Does it have settings to not show images? The question I'm asking is, could the user's settings prevent the image from being shown?

    And there is an example in the codebank section that you posted a reply too. Is that not working for you?
    Last edited by LaVolpe; Mar 27th, 2011 at 10:57 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    Addicted Member
    Join Date
    Sep 2009
    Posts
    190

    Re: VB6 - EMail - JPEG IMAGE

    Ups, I see now "img src='cid:"...
    I didn't know for that, but must try imediatelly!

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: VB6 - EMail - JPEG IMAGE

    Have you tried the original code? (http://www.vbforums.com/showpost.php...97&postcount=1)
    How about testing with a regular jpg image file that is not created by code in order to isolate any image creation issues?

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    48

    Re: VB6 - EMail - JPEG IMAGE

    Hi all,
    I checked the properties of the image saved and its showing "JPEG Image" only. I tried the code given in http://www.vbforums.com/showpost.php...97&postcount=1 also but it didnt work out. I dont follow where i am getting wrong

  8. #8

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    48

    Re: VB6 - EMail - JPEG IMAGE

    And its a bitmap image size wont be much less. The size of the image that is getting saved is 250kb. In outlook tools->options also mail format is in HTML only. Still i am not getting the code working

  9. #9

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    48

    Re: VB6 - EMail - JPEG IMAGE

    @LaVolpe: I am not getting any error. but i find some symbol in the body of email but nothing is loaded in recipient's mail And even the code in the link given didnt help me out with the problem. I am sending mail to another (different) mail id only. I find the image loaded in start->run-> C:\...\imagefile.jpeg and i tried saving it as bitmap and embedded also and even it didnt work out

  10. #10

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    48

    Re: VB6 - EMail - JPEG IMAGE

    And also i tried embedding a different image in my system(which is not generated out of code) but not worth

  11. #11

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    48

    Re: VB6 - EMail - JPEG IMAGE

    Guys thank you so much 2 each and every1 of u I got it done with this line of code

    .HTMLBody = "<HTML><img src='C:\TITAN\imagefile.jpg' alt='' width=300 height=300></HTML>"

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: VB6 - EMail - JPEG IMAGE

    Quote Originally Posted by gowriv89 View Post
    Guys thank you so much 2 each and every1 of u I got it done with this line of code

    .HTMLBody = "<HTML><img src='C:\TITAN\imagefile.jpg' alt='' width=300 height=300></HTML>"
    Just noticed what you were doing wrong. You werent attaching the image before setting the htmlbody property.

    Code:
    Set colAttach = oEmail.Attachments
    Set oAttach = colAttach.Add("D:\my documents\MyPic.jpg")
    oEmail.Close olSave
    Without it being actually attached, the "cid" tag wont work.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13
    New Member
    Join Date
    Jul 2011
    Posts
    2

    Re: VB6 - EMail - JPEG IMAGE

    @gowriv89 can you please post your working code here. i am tring to do the same but not able to achieve the result

  14. #14
    New Member
    Join Date
    Jul 2011
    Posts
    2

    Re: VB6 - EMail - JPEG IMAGE

    can any help me please


    vb Code:
    1. Set colAttach = olMail.Attachments
    2. Set oAttach = colAttach.Add("D:\wall papers\leaf.jpg")
    3.  i first attached  the image then  i am using below code buts its not showing image to receiver . it shows me the image in sent message but receiver is not able to see it
    4.  
    5.     With olMail

    vb Code:
    1. .BodyFormat = olFormatHTML
    2.         .HTMLBody = "<HTML><img src='D:\wall papers\leaf.jpg' alt='' width=300 height=300></HTML>"

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