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: -
-
Sub Email_DPV()
-
Dim oFolder As Outlook.MAPIFolder
-
Dim oItem As Outlook.MailItem
-
Dim oOutlook As New Outlook.Application
-
Dim MoOutlook As Outlook.Namespace
-
Set MoOutlook = oOutlook.GetNamespace("MAPI")
-
Set oFolder = MoOutlook.GetDefaultFolder(olFolderOutbox)
-
Set oItem = oFolder.Items.Add(olMailItem)
-
Sheets("Summary").Range("AE3").Font.Bold = True
-
With oItem
-
.Recipients.Add ("iain.dykes@ocado.com")
-
.Subject = "Next Day AM/PM Balance"
-
.Body = Sheets("Summary").Range("AE3") & vbNewLine & _
-
Sheets("Summary").Range("AD4") & Sheets("Summary").Range("AE4") & vbNewLine & _
-
Sheets("Summary").Range("AD5") & " " & Round(Sheets("Summary").Range("AE5"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD6") & " " & Round(Sheets("Summary").Range("AE6"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD7") & " " & Round(Sheets("Summary").Range("AE7"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD8") & " " & Round(Sheets("Summary").Range("AE8"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD9") & " " & Round(Sheets("Summary").Range("AE9"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD10") & " " & Round(Sheets("Summary").Range("AE10"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD11") & " " & Round(Sheets("Summary").Range("AE11"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD13") & Sheets("Summary").Range("AE13") & vbNewLine & _
-
Sheets("Summary").Range("AD14") & " " & Round(Sheets("Summary").Range("AE14"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD15") & " " & Round(Sheets("Summary").Range("AE15"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD16") & " " & Round(Sheets("Summary").Range("AE16"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD17") & " " & Round(Sheets("Summary").Range("AE17"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD18") & " " & Round(Sheets("Summary").Range("AE18"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD19") & " " & Round(Sheets("Summary").Range("AE19"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD20") & " " & Round(Sheets("Summary").Range("AE20"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD22") & Sheets("Summary").Range("AE22") & vbNewLine & _
-
Sheets("Summary").Range("AD23") & " " & Round(Sheets("Summary").Range("AE23"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD24") & " " & Round(Sheets("Summary").Range("AE24"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD25") & " " & Round(Sheets("Summary").Range("AE25"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD26") & " " & Round(Sheets("Summary").Range("AE26"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD27") & " " & Round(Sheets("Summary").Range("AE27"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD28") & " " & Round(Sheets("Summary").Range("AE28"), 0) & vbNewLine & _
-
Sheets("Summary").Range("AD29") & " " & Round(Sheets("Summary").Range("AE29"), 0)
-
.Importance = olImportanceNormal
-
.Send
-
End With
-
Set oItem = Nothing
-
Set oFolder = Nothing
-
End Sub
-
If anyone has any suggestions then they would be very gratefully received.
Thanks.
0 1185 Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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)
|
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...
|
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...
|
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...
|
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...
|
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...
|
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?
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |