473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Sending Range of Excel in Body of Email

I have finally worked out how to automatically send a range of cells in the body of an email using Outlook but it is very clumsy and I have to build up the email using the limit of line continuations. Is there any quicker and easier way of sending this email as it is always a set range of cells that I want to sent. At the moment my code looks like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Sub Email_DPV()
  3. Dim oFolder As Outlook.MAPIFolder
  4. Dim oItem As Outlook.MailItem
  5. Dim oOutlook As New Outlook.Application
  6. Dim MoOutlook As Outlook.Namespace
  7. Set MoOutlook = oOutlook.GetNamespace("MAPI")
  8. Set oFolder = MoOutlook.GetDefaultFolder(olFolderOutbox)
  9. Set oItem = oFolder.Items.Add(olMailItem)
  10. Sheets("Summary").Range("AE3").Font.Bold = True
  11. With oItem
  12.     .Recipients.Add ("iain.dykes@ocado.com")
  13.     .Subject = "Next Day AM/PM Balance"
  14.     .Body = Sheets("Summary").Range("AE3") & vbNewLine & _
  15.     Sheets("Summary").Range("AD4") & Sheets("Summary").Range("AE4") & vbNewLine & _
  16.     Sheets("Summary").Range("AD5") & "            " & Round(Sheets("Summary").Range("AE5"), 0) & vbNewLine & _
  17.     Sheets("Summary").Range("AD6") & "      " & Round(Sheets("Summary").Range("AE6"), 0) & vbNewLine & _
  18.     Sheets("Summary").Range("AD7") & "         " & Round(Sheets("Summary").Range("AE7"), 0) & vbNewLine & _
  19.     Sheets("Summary").Range("AD8") & "          " & Round(Sheets("Summary").Range("AE8"), 0) & vbNewLine & _
  20.     Sheets("Summary").Range("AD9") & "     " & Round(Sheets("Summary").Range("AE9"), 0) & vbNewLine & _
  21.     Sheets("Summary").Range("AD10") & "  " & Round(Sheets("Summary").Range("AE10"), 0) & vbNewLine & _
  22.     Sheets("Summary").Range("AD11") & "              " & Round(Sheets("Summary").Range("AE11"), 0) & vbNewLine & _
  23.     Sheets("Summary").Range("AD13") & Sheets("Summary").Range("AE13") & vbNewLine & _
  24.     Sheets("Summary").Range("AD14") & "          " & Round(Sheets("Summary").Range("AE14"), 0) & vbNewLine & _
  25.     Sheets("Summary").Range("AD15") & "     " & Round(Sheets("Summary").Range("AE15"), 0) & vbNewLine & _
  26.     Sheets("Summary").Range("AD16") & "        " & Round(Sheets("Summary").Range("AE16"), 0) & vbNewLine & _
  27.     Sheets("Summary").Range("AD17") & "         " & Round(Sheets("Summary").Range("AE17"), 0) & vbNewLine & _
  28.     Sheets("Summary").Range("AD18") & "    " & Round(Sheets("Summary").Range("AE18"), 0) & vbNewLine & _
  29.     Sheets("Summary").Range("AD19") & "  " & Round(Sheets("Summary").Range("AE19"), 0) & vbNewLine & _
  30.     Sheets("Summary").Range("AD20") & "              " & Round(Sheets("Summary").Range("AE20"), 0) & vbNewLine & _
  31.     Sheets("Summary").Range("AD22") & Sheets("Summary").Range("AE22") & vbNewLine & _
  32.     Sheets("Summary").Range("AD23") & "          " & Round(Sheets("Summary").Range("AE23"), 0) & vbNewLine & _
  33.     Sheets("Summary").Range("AD24") & "     " & Round(Sheets("Summary").Range("AE24"), 0) & vbNewLine & _
  34.     Sheets("Summary").Range("AD25") & "        " & Round(Sheets("Summary").Range("AE25"), 0) & vbNewLine & _
  35.     Sheets("Summary").Range("AD26") & "         " & Round(Sheets("Summary").Range("AE26"), 0) & vbNewLine & _
  36.     Sheets("Summary").Range("AD27") & "    " & Round(Sheets("Summary").Range("AE27"), 0) & vbNewLine & _
  37.     Sheets("Summary").Range("AD28") & "  " & Round(Sheets("Summary").Range("AE28"), 0) & vbNewLine & _
  38.     Sheets("Summary").Range("AD29") & "              " & Round(Sheets("Summary").Range("AE29"), 0)
  39.     .Importance = olImportanceNormal
  40.     .Send
  41. End With
  42. Set oItem = Nothing
  43. Set oFolder = Nothing
  44. End Sub
  45.  
If anyone has any suggestions then they would be very gratefully received.

Thanks.
Jul 21 '08 #1
0 1185

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Niyazi | last post by:
Hi, I have to retrieve a data from AS400 DB2 and after working with data I have to export into one of existing Excel file. I can connect into specific library in AS400 DB2 using AS400...
10
by: Maik | last post by:
Hello, I've got a problem with access to special ranges. I renamed some cells (for example "C4" in "CUSTOM.GENERAL.VPRIM"). This is necessary, because I have to read out only these cells in...
4
by: IMS.Rushikesh | last post by:
Hi All, I am trying to execute below code but it gives me an COMException ///// Code Start //// public string GetName(Excel.Range range) { try { if (range.Name != null)
3
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
2
by: mkadasi | last post by:
Hello Everyone, I facing a problem in sending mail through vb.net. The code written below sends the mail to the respective person specified in the 'TO' address. But the problem is that the...
1
by: rciiipo | last post by:
I have a question that is similar to a thread started by pauljhorak; however, my needs are a bit different / possibly more complicated. I have several files stored as outlook items (.msg). I...
0
by: damimkader | last post by:
Hi, I'm trying to send emails using a Macro based on an Excel Sheet and the Email Client I'm using is Lotus Notes. OS used - Windows Xp. Language - VB Below is the Code I'm using for doing...
1
by: the_ricka | last post by:
Hi all, I'm fairly new to python, but very excited about it's potential. I'm trying to write a simple program that will accept input from a command line and send email. The parameters I used on...
1
by: miketroy1 | last post by:
I would like to paste a range into the email body. VBA is not working well with that concept. Does the range need to convert to a string to be pasted into the body of email? How is that done? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.