|
-
Mar 27th, 2011, 06:52 AM
#1
Thread Starter
Member
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
-
Mar 27th, 2011, 07:32 AM
#2
Addicted Member
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
-
Mar 27th, 2011, 10:21 AM
#3
Addicted Member
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]" />
-
Mar 27th, 2011, 10:32 AM
#4
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.
-
Mar 27th, 2011, 10:59 AM
#5
Addicted Member
Re: VB6 - EMail - JPEG IMAGE
Ups, I see now "img src='cid:"...
I didn't know for that, but must try imediatelly!
-
Mar 30th, 2011, 08:25 AM
#6
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Apr 3rd, 2011, 06:29 AM
#7
Thread Starter
Member
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
-
Apr 3rd, 2011, 06:32 AM
#8
Thread Starter
Member
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
-
Apr 3rd, 2011, 06:57 AM
#9
Thread Starter
Member
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
-
Apr 3rd, 2011, 06:59 AM
#10
Thread Starter
Member
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
-
Apr 3rd, 2011, 07:14 AM
#11
Thread Starter
Member
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>"
-
Apr 5th, 2011, 11:32 AM
#12
Re: VB6 - EMail - JPEG IMAGE
 Originally Posted by gowriv89
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jul 22nd, 2011, 10:41 PM
#13
New Member
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
-
Jul 26th, 2011, 09:49 AM
#14
New Member
Re: VB6 - EMail - JPEG IMAGE
can any help me please
vb Code:
Set colAttach = olMail.Attachments Set oAttach = colAttach.Add("D:\wall papers\leaf.jpg") 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 With olMail
vb Code:
.BodyFormat = olFormatHTML .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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|