is it working now
On Tue, Nov 19, 2013 at 3:46 PM, Farrukh Shaikh <fj.shaik...@gmail.com>wrote: > i have done that also .! & some of the images are attached as an > attachment and against them there is a red cross in the email body, and > some images are attached in the email body. > > > > > On Tue, Nov 19, 2013 at 2:22 PM, <koul.ash...@gmail.com> wrote: > >> You need to attach the images as well >> Sent on my BlackBerry® from Vodafone >> ------------------------------ >> *From: * Farrukh Shaikh <fj.shaik...@gmail.com> >> *Sender: * excel-macros@googlegroups.com >> *Date: *Tue, 19 Nov 2013 13:10:50 +0500 >> *To: *<excel-macros@googlegroups.com> >> *ReplyTo: * excel-macros@googlegroups.com >> *Subject: *Re: $$Excel-Macros$$ Stuck in attaching multiple image files >> in email body >> >> Thanks ashish koul, i tried and its working now but in a slightly >> different way .! here is the line : >> >> uuu = Mid(sImgPath, InStrRev(sImgPath, "\") + 1) >> HTML = HTML + "<img src='cid:" & uuu & "'><br><br>" >> .HTMLbody HTML >> >> But now the images in the body are shown as red cross rather then the >> whole image. >> suggestions are anxiously awaited. >> >> Regards. >> >> >> On Mon, Nov 18, 2013 at 11:29 PM, ashish koul <koul.ash...@gmail.com>wrote: >> >>> try something like this >>> Sub sample_macro() >>> >>> >>> Dim objOL As Object >>> Dim olMail As Object >>> Dim bdy As String >>> >>> >>> For Each itm In Array("C:\Users\Public\Pictures\Sample >>> Pictures\desert.jpg", "C:\Users\Public\Pictures\Sample Pictures\tulips.jpg") >>> bdy = bdy & "<p align='Left'><img src=""cid:" & Mid(itm, >>> InStrRev(itm, "\") + 1) & """ width=700 height=500 > <br> <br>" >>> Next itm >>> >>> >>> 'send the email >>> >>> Set objOL = CreateObject("Outlook.Application") >>> Set olMail = objOL.CreateItem(olMailItem) >>> >>> With olMail >>> .To = "koul.ash...@gmail.com" >>> .Subject = "Add Chart in outlook mail body" >>> For Each itm In Array("C:\Users\Public\Pictures\Sample >>> Pictures\desert.jpg", "C:\Users\Public\Pictures\Sample Pictures\tulips.jpg") >>> .Attachments.Add itm >>> Next >>> .HTMLBody = "hello <br>" & bdy & "<br> thanks" >>> .Display >>> End With >>> >>> >>> Set olMail = Nothing >>> Set olApp = Nothing >>> >>> End Sub >>> >>> >>> >>> >>> replace for loop with ur excat loop >>> >>> >>> On Fri, Nov 15, 2013 at 9:56 PM, Farrukh Shaikh >>> <fj.shaik...@gmail.com>wrote: >>> >>>> Dear Coders, >>>> iam new to VBA, was trying to automate my work, this is the last step >>>> of my task, some images are stored at a path ( here the path is in sImgPath >>>> ) when i try to insert the image in the email, first image is inserted >>>> properly, but when there is the second iteration, it deletes the previous >>>> complete email body and insert the new image. i have died trying stuff to >>>> bypass this issue. >>>> please help me out, would be really grateful to you. ( also i can not >>>> replications of code as the number of images stored on the path is not >>>> fixed, it can change on daily basis.) >>>> >>>> Thanks in advance. >>>> >>>> Here is the code i am using. >>>> >>>> Sub Create_Email() >>>> >>>> Dim objOL As Object >>>> Dim sImgPath As String >>>> Dim olMail As MailItem >>>> Dim sHi As String >>>> Dim sBody As String >>>> Dim sThanks As String >>>> >>>> Dim path_a As String, path_b As String, C_Path As String, path_before >>>> As String, image_names() As String >>>> >>>> path_before = Cells(7, 9).Value >>>> >>>> path_a = Cells(7, 10).Value ' contains path of issues folder >>>> 'path_b = Cells(8, 10).Value ' contais bsc name >>>> C_Path = path_before & "\" & path_a ' Now C_Path has the complete path >>>> for taking images for attachemnet in the mail >>>> >>>> '****** check number of files in the folders >>>> >>>> >>>> Dim MyFile As String >>>> Dim count As Integer, j As Integer >>>> MyFile = Dir(C_Path & "\" & path_b & "*.jpg") >>>> >>>> GoTo Line1 >>>> >>>> ' this loop will store all the names of images in the >>>> folder to the array - > image_names() >>>> >>>> Do While MyFile <> "" >>>> MyFile = Dir >>>> If MyFile = "" Then >>>> GoTo Line2 >>>> Else >>>> End If >>>> >>>> Line1: >>>> ReDim Preserve image_names(count) >>>> image_names(count) = MyFile >>>> count = count + 1 ' at the end of loop count will contain >>>> # of images >>>> Loop >>>> 'MsgBox j & " files found" >>>> >>>> 'Creating The EMAIL >>>> >>>> Line2: >>>> Set objOL = CreateObject("Outlook.Application") >>>> Set olMail = objOL.CreateItem(olMailItem) >>>> With olMail >>>> >>>> .To = "myem...@mydomain.com" >>>> .Subject = "NPO Issue :: Huawei :: " & path_a >>>> For j = 0 To count - 1 >>>> sImgPath = C_Path & "\" & image_names(j) >>>> uuu = Mid(sImgPath, InStrRev(sImgPath, "\") + 1) >>>> sHi = "<font size='3' color='black'>" & "Hi," & "<br> <br>" & "Here is >>>> the required solution: " & "<br> <br>" >>>> >>>> ' in the variable sImgPath i have the file name along with the >>>> extension ---> .jpg in my case >>>> sBody = "<p align='Left'><img src=" & sImgPath & """ width=700 height= >>>> 350 > <br> <br> <br> <br> <br> <br> <br> <br> " >>>> >>>> olMail.HTMLBody = sBody >>>> .Display >>>> Next j >>>> End With >>>> >>>> 'Free-up the objects >>>> Set olMail = Nothing >>>> Set olApp = Nothing >>>> >>>> End Sub >>>> >>>> >>>> -- >>>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? >>>> It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >>>> https://www.facebook.com/discussexcel >>>> >>>> FORUM RULES >>>> >>>> 1) Use concise, accurate thread titles. Poor thread titles, like Please >>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice >>>> will not get quick attention or may not be answered. >>>> 2) Don't post a question in the thread of another member. >>>> 3) Don't post questions regarding breaking or bypassing any security >>>> measure. >>>> 4) Acknowledge the responses you receive, good or bad. >>>> 5) Jobs posting is not allowed. >>>> 6) Sharing copyrighted material and their links is not allowed. >>>> >>>> NOTE : Don't ever post confidential data in a workbook. Forum owners >>>> and members are not responsible for any loss. >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "MS EXCEL AND VBA MACROS" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to excel-macros+unsubscr...@googlegroups.com. >>>> To post to this group, send email to excel-macros@googlegroups.com. >>>> Visit this group at http://groups.google.com/group/excel-macros. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>> >>> >>> >>> -- >>> *Regards* >>> >>> *Ashish Koul* >>> >>> >>> *Visit* >>> http://www.excelvbamacros.in >>> Like Us on >>> Facebook<http://www.facebook.com/pages/Excel-VBA-Codes-Macros/151803898222297> >>> Join Us on Facebook <http://www.facebook.com/groups/163491717053198/> >>> >>> >>> P Before printing, think about the environment. >>> >>> >>> >>> -- >>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? >>> It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >>> https://www.facebook.com/discussexcel >>> >>> FORUM RULES >>> >>> 1) Use concise, accurate thread titles. Poor thread titles, like Please >>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice >>> will not get quick attention or may not be answered. >>> 2) Don't post a question in the thread of another member. >>> 3) Don't post questions regarding breaking or bypassing any security >>> measure. >>> 4) Acknowledge the responses you receive, good or bad. >>> 5) Jobs posting is not allowed. >>> 6) Sharing copyrighted material and their links is not allowed. >>> >>> NOTE : Don't ever post confidential data in a workbook. Forum owners and >>> members are not responsible for any loss. >>> --- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "MS EXCEL AND VBA MACROS" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/excel-macros/c1zIOQgKMtc/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> excel-macros+unsubscr...@googlegroups.com. >>> To post to this group, send email to excel-macros@googlegroups.com. >>> Visit this group at http://groups.google.com/group/excel-macros. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- >> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s >> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >> https://www.facebook.com/discussexcel >> >> FORUM RULES >> >> 1) Use concise, accurate thread titles. Poor thread titles, like Please >> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice >> will not get quick attention or may not be answered. >> 2) Don't post a question in the thread of another member. >> 3) Don't post questions regarding breaking or bypassing any security >> measure. >> 4) Acknowledge the responses you receive, good or bad. >> 5) Jobs posting is not allowed. >> 6) Sharing copyrighted material and their links is not allowed. >> >> NOTE : Don't ever post confidential data in a workbook. Forum owners and >> members are not responsible for any loss. >> --- >> You received this message because you are subscribed to the Google Groups >> "MS EXCEL AND VBA MACROS" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to excel-macros+unsubscr...@googlegroups.com. >> To post to this group, send email to excel-macros@googlegroups.com. >> Visit this group at http://groups.google.com/group/excel-macros. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> -- >> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s >> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >> https://www.facebook.com/discussexcel >> >> FORUM RULES >> >> 1) Use concise, accurate thread titles. Poor thread titles, like Please >> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice >> will not get quick attention or may not be answered. >> 2) Don't post a question in the thread of another member. >> 3) Don't post questions regarding breaking or bypassing any security >> measure. >> 4) Acknowledge the responses you receive, good or bad. >> 5) Jobs posting is not allowed. >> 6) Sharing copyrighted material and their links is not allowed. >> >> NOTE : Don't ever post confidential data in a workbook. Forum owners and >> members are not responsible for any loss. >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "MS EXCEL AND VBA MACROS" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/excel-macros/c1zIOQgKMtc/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> excel-macros+unsubscr...@googlegroups.com. >> To post to this group, send email to excel-macros@googlegroups.com. >> Visit this group at http://groups.google.com/group/excel-macros. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/groups/opt_out. > -- *Regards* *Ashish Koul* *Visit* http://www.excelvbamacros.in Like Us on Facebook<http://www.facebook.com/pages/Excel-VBA-Codes-Macros/151803898222297> Join Us on Facebook <http://www.facebook.com/groups/163491717053198/> P Before printing, think about the environment. -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/groups/opt_out.