e-mail problem can anyone help?

liammoohan

Board Regular
Joined
Jan 11, 2008
Messages
72
I am sending an e-mail through outlook using the olmail function. Below is the code I am using.

The issue I am having is that the e-mail will not generate when I add on the part that is highlighted red. It is returning a syntax error. Can anyone please advise how this can be done.

Sub newstartermail()

Request = Range("O24").Value
RequestID = Range("M17").Value
SaveFileCS = Range("B35").Value
SaveFileHR = Range("B36").Value
SaveFileITS = Range("B37").Value
SaveFileCASEFLOW = Range("B38").Value
SaveFileSECURITY = Range("B39").Value
SaveFileGENERAL = Range("B40").Value
Date = Range("F17").Value

Dim olmail As Outlook.MailItem
Dim olapp As New Outlook.Application

Set olmail = olapp.CreateItem(olMailItem)

With olmail

.To = ("email@email.co.uk")
.CC = ("")
.Subject = ("New Starter Request " & Date)
.Body = ("Hello" & Chr(10) & Chr(10) & "Your " & Request & " Request #" & RequestID & " has been raised." & Chr(10) & Chr(10) & "You will receive confirmation once your request has been completed." & Chr(10) & Chr(10) & "For Administration Use Only" & Chr(10) & Chr(10) & "Contact Strategy - " & "<\\Liam\Agent Administration Suite\CS>" & "As file name " & SaveFileCS & ".xls" & Chr(10) & "Human Resources - " & "<\\Liam\Agent Administration Suite\HR>" & "As file name " & SaveFileHR & ".xls" & Chr(10) & "IT Support - " & "<\\Liam\Agent Administration Suite\ITS>" & "As file name " & SaveFileITS & ".xls" & Chr(10) & "Caseflow - " & "<\\Liam\Agent Administration Suite\CASEFLOW>" & "As file name " & SaveFileCASEFLOW & ".xls" & Chr(10) & "Security/Reception - " & "<\\Liam\Agent Administration Suite\SECURITY>" & "As file name " & SaveFileSECURITY & ".xls"
& Chr(10) & Chr(10) & "General Viewing - " & "<\\Liam\Agent Administration Suite\GENERAL>" & "As file name " & SaveFileGENERAL & ".xls")


.Categories = (WeekCom)
.Display

End With

End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

westconn1

Board Regular
Joined
Feb 20, 2009
Messages
245
is this all on the same line in the code window,if not you will need line continuation
like
Code:
mystr = "this" _
& " is continued on the next line"
 
Upvote 0

Forum statistics

Threads
1,191,524
Messages
5,987,103
Members
440,079
Latest member
MarchePR

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top