mdmackillop
11-08-2005, 03:57 PM
Hi All,
I'm using the following code from Excel to create an email ("16" replaces a workbook reference). Two questions.
What do I have to add to open Outlook, making the email visible for final editing before sending?
I've used the name of a mailing list in .to = "Valuations" which doesn't work. Can this be made to work, or do I just have to add the recipients to the code?
Regards
Malcolm
Sub eMailValuation()
Dim OL As Object
Dim EmailItem As Object
Dim Wb As Workbook
Dim MySub As String
Dim MyText As String
Dim MyVal As String
Dim MySum As String
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Wb = ActiveWorkbook
MySub = "Kitchen Project - Valuation No. " & "16"
MyText = "Please find attached our Valuation No. " & "16" & _
" together with a list of included properties." & vbCr & vbCr & _
"Regards," & vbCr & vbCr & "Malcolm"
MyVal = "F:\Valuations\Val" & Format("16", "000") & ".mdi"
MySum = "F:\Valuations\Summary.mdi"
Wb.Save
With EmailItem
.Subject = MySub
.Body = MyText
.To = "Valuations"
.Importance = olImportanceNormal
'.Attachments.Add MyVal
'.Attachments.Add MySum
.Save
End With
Application.ScreenUpdating = True
Set Wb = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub
I'm using the following code from Excel to create an email ("16" replaces a workbook reference). Two questions.
What do I have to add to open Outlook, making the email visible for final editing before sending?
I've used the name of a mailing list in .to = "Valuations" which doesn't work. Can this be made to work, or do I just have to add the recipients to the code?
Regards
Malcolm
Sub eMailValuation()
Dim OL As Object
Dim EmailItem As Object
Dim Wb As Workbook
Dim MySub As String
Dim MyText As String
Dim MyVal As String
Dim MySum As String
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Wb = ActiveWorkbook
MySub = "Kitchen Project - Valuation No. " & "16"
MyText = "Please find attached our Valuation No. " & "16" & _
" together with a list of included properties." & vbCr & vbCr & _
"Regards," & vbCr & vbCr & "Malcolm"
MyVal = "F:\Valuations\Val" & Format("16", "000") & ".mdi"
MySum = "F:\Valuations\Summary.mdi"
Wb.Save
With EmailItem
.Subject = MySub
.Body = MyText
.To = "Valuations"
.Importance = olImportanceNormal
'.Attachments.Add MyVal
'.Attachments.Add MySum
.Save
End With
Application.ScreenUpdating = True
Set Wb = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub