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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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,214,606
Messages
6,120,484
Members
448,967
Latest member
visheshkotha

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
Back
Top