I have the following macro but i it doen't seem to work please help. The macro falls down at outlook reference.
I have enabled the reference Microsoft outlook 10.0 object library,
PLEASE HELP!!!
EDIT: Added Code tags - Moderator
I have enabled the reference Microsoft outlook 10.0 object library,
PLEASE HELP!!!
Code:
Sub Mail_New_Deal_Customer()
Sheets("New Deal").Copy
Nametosave = Cells(2, 3).Value & " " & Cells(3, 4).Value
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"\\C:\Documents and Settings\user\Desktop\W Communications Operations Model\" + Nametosave, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Application.DisplayAlerts = True
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.Save
'This example send the last saved version of the Activeworkbook
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = Cells(63, 5).Text
.CC = ""
.BCC = ""
.Subject = "New Deal " & Cells(3, 4).Text
.Body = "Please find enclosed details of your new mobile contract for your consideration. If you have any discrepancies or any queries please contact" & Cells(63, 11).Text
.Attachments.Add ActiveWorkbook.FullName
.Attachments.Add ("C:\Documents and Settings\user\Desktop\W Communications Operations Model\Current Tariffs\" & Cells(9, 22).Text & ".pts")
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.send 'or use .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
ActiveWorkbook.Close
End Sub
EDIT: Added Code tags - Moderator