Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default vba routine in Excel 2002 to create varying size email in Outlook

This procedure runs in Excel.
It creates an email message based on the data in a worksheet.
It works perfectly, but where I'm stuck is in how to make the loop work.
That is, how do I add an extra line to the message in Outlook if 2 items are
purchased.

Option Explicit
Sub Outlook_Message_Purchases()
Dim objApp As Outlook.Application
Dim objMessage As Outlook.MailItem
Dim msg As String
Dim itemx As String
Dim Amountx As Currency, SubTotal As Currency
Dim sFirstName As String, email As String, Total As Currency, Postage As
Currency
Dim x As Integer

For x = 1 To 1 ' number of items purchased

itemx = Cells(17, x + 1)
Amountx = Cells(17, x + 2)

email = Cells(15, 2)
SubTotal = Amountx
Postage = Cells(25, 3) ' Postage line 25
Total = SubTotal + Postage

msg = msg & "Dear " & sFirstName & "," & vbCrLf & vbCrLf
msg = msg & itemx & vbTab & Format(Amountx, "$#,##0.00") & vbCrLf
msg = msg & "Your total purchases come to: " & Format(SubTotal,
"$#,##0.00") & vbCrLf
msg = msg & "The total including postage of " & Format(Postage,
"$#,##0.00") _
& " is " & Format(Total, "$#,##0.00") & vbCrLf

Next x

Set objApp = CreateObject("Outlook.Application")
Set objMessage = objApp.CreateItem(olMailItem)
With objMessage
.To = email
.BCC = "
.Subject = "Your Purchases"
.Body = msg
End With
objMessage.Display

Set objApp = Nothing
Set objMessage = Nothing

End Sub


--
Regards,
David


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Outlook email from Excel DoooWhat Excel Discussion (Misc queries) 1 April 9th 07 07:20 PM
Outlook 2002 calendar dates exported to Excel 2002 sort incorrectl scampbell Excel Worksheet Functions 0 February 22nd 06 06:31 PM
Sheet vs File size when sending email in Outlook matchball Excel Discussion (Misc queries) 0 January 4th 06 07:48 PM
How do I get excel to create an email using Outlook? cleslie Excel Discussion (Misc queries) 0 November 30th 05 12:11 AM
Excel 2002 files attached to Outlook 2002 EMails change size AJStadlin Excel Programming 1 October 15th 03 12:12 AM


All times are GMT +1. The time now is 05:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"