missrutele
New Member
- Joined
- Nov 17, 2017
- Messages
- 10
Hello,
i need to form body text from excel to send via outlook. One problem, that sometimes in can be 10 names and surnames, or it can be 5 names and surnames. After list goes normal text and signature.
I have this one, from K20 goes fixed text, but from K12 until K20 goes list of people, sometimes it can be shorter than 8 rows so when in email I see a lot of spaces, how can I fix it?:
Sub SendMail()
'SendEmail Macro
'
'
Dim outlApp As Outlook.Application
Set outlApp = CreateObject("Outlook.Application")
Dim outlMail As Outlook.MailItem
Set outlMail = outlApp.CreateItem(outlMailItem)
outlMail.To = Range("K5") ' <-- Put email of the recipient here
outlMail.Subject = "19V69 nuotoliniai mokymai ir prizai"
outlMail.CC = Range("K6") ' <-- Put email of 'copy to' recipient here
outlMail.HTMLBody = Range("K8").Value & "<br><br>" _
& Range("K9").Value & "<br><br>" _
& Range("K10").Value & "<br><br>" _
& Range("K11").Value & "<br><br>" _
& Range("K12").Value & "<br><br>" _
& Range("K13").Value & "<br><br>" _
& Range("K14").Value & "<br><br>" _
& Range("K15").Value & "<br><br>" _
& Range("K16").Value & "<br><br>" _
& Range("K17").Value & "<br><br>" _
& Range("K18").Value & "<br><br>" _
& Range("K19").Value & "<br><br>" _
& Range("K20").Value & "<br><br>" _
& Range("K21").Value & "<br><br>" _
& Range("K22").Value & "<br><br>" _
& Range("K23").Value & vbLf _
outlMail.send
Set outlApp = Nothing
Range("D12").Value = Range("D12").Value + 1
End Sub
Thank you
i need to form body text from excel to send via outlook. One problem, that sometimes in can be 10 names and surnames, or it can be 5 names and surnames. After list goes normal text and signature.
I have this one, from K20 goes fixed text, but from K12 until K20 goes list of people, sometimes it can be shorter than 8 rows so when in email I see a lot of spaces, how can I fix it?:
Sub SendMail()
'SendEmail Macro
'
'
Dim outlApp As Outlook.Application
Set outlApp = CreateObject("Outlook.Application")
Dim outlMail As Outlook.MailItem
Set outlMail = outlApp.CreateItem(outlMailItem)
outlMail.To = Range("K5") ' <-- Put email of the recipient here
outlMail.Subject = "19V69 nuotoliniai mokymai ir prizai"
outlMail.CC = Range("K6") ' <-- Put email of 'copy to' recipient here
outlMail.HTMLBody = Range("K8").Value & "<br><br>" _
& Range("K9").Value & "<br><br>" _
& Range("K10").Value & "<br><br>" _
& Range("K11").Value & "<br><br>" _
& Range("K12").Value & "<br><br>" _
& Range("K13").Value & "<br><br>" _
& Range("K14").Value & "<br><br>" _
& Range("K15").Value & "<br><br>" _
& Range("K16").Value & "<br><br>" _
& Range("K17").Value & "<br><br>" _
& Range("K18").Value & "<br><br>" _
& Range("K19").Value & "<br><br>" _
& Range("K20").Value & "<br><br>" _
& Range("K21").Value & "<br><br>" _
& Range("K22").Value & "<br><br>" _
& Range("K23").Value & vbLf _
outlMail.send
Set outlApp = Nothing
Range("D12").Value = Range("D12").Value + 1
End Sub
Thank you