Hi all,
I have set up an if formula that ends with sending an automatice email. this is working 100% fine.
I want to send a different email based on a another set of rules but I keep getting a Syntax error.
My original VBA is :-
Sub MailOutlook16()
'By Martin Nesbitt @ MJNSystems
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Village/Sceme - " & [$c10] & vbNewLine & vbNewLine & "Work Request " & [$D16] & vbNewLine & vbNewLine & GetUserName & " has requested a new PO value above the value of £1000" & vbNewLine & vbNewLine & _
"Requested new value - £" & [$ae16] & vbNewLine & vbNewLine & "Please evaluate this request and either Authorise or Reject as appropriate"
On Error Resume Next
With xOutMail
.To = "Kevin.tanner@extracare.org.uk"
.CC = [c9]
.BCC = ""
.Subject = "SCM - Purchase Order Increase Request"
.Body = xMailBody
.display 'use .Send or .display
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
I want to be able to also send out :-
Sub MailOrder16()
'By Martin Nesbitt @ MJNSystems
Dim OutApp As Object
Dim OutMail As Object
Dim MailBody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
MailBody = "Village/Sceme - " & [$c10] & vbNewLine & vbNewLine & "Work Request " & [$D16] & vbNewLine & vbNewLine & _
GetUserName & " has requested you attend " & [c16] & vbNewLine & vbNewLine & "UPRN I.D. - " & [B16] & vbNewLine & vbNewLine & _
" The triaged repair description is - " & [AC16] & vbNewLine & vbNewLine & "The Job Priority has been set as " & [t16] & " which is " & [bn16] & " response" & vbNewLine & vbNewLine & _
"Your Initial Po Value has been set at - £" & [$ad16] & vbNewLine & vbNewLine & _
"Please confirm receipt of this Require with Engineer ETA to Inbox repairrequest@extracare.org.uk"
On Error Resume Next
With OutMail
.To = [Bq16]
.CC = "repairrequest@extracare.org.uk"
.BCC = ""
.Subject = "Request to attend Repair Request"
.Body = MailBody
.display 'use .Send or .display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
I get the message
The Syntax of this name isn't correct.
Verify that the name:
-Starts with a letter or Underscore(_)
_Doesn't include a space or character that isnt allowed
_Doesn't conflict with an existing name in the workbook.
I have used the formula =if(M16<>"Select Contactor",MailOrder16(),"")
can anybody offer help
Thanks
I have set up an if formula that ends with sending an automatice email. this is working 100% fine.
I want to send a different email based on a another set of rules but I keep getting a Syntax error.
My original VBA is :-
Sub MailOutlook16()
'By Martin Nesbitt @ MJNSystems
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Village/Sceme - " & [$c10] & vbNewLine & vbNewLine & "Work Request " & [$D16] & vbNewLine & vbNewLine & GetUserName & " has requested a new PO value above the value of £1000" & vbNewLine & vbNewLine & _
"Requested new value - £" & [$ae16] & vbNewLine & vbNewLine & "Please evaluate this request and either Authorise or Reject as appropriate"
On Error Resume Next
With xOutMail
.To = "Kevin.tanner@extracare.org.uk"
.CC = [c9]
.BCC = ""
.Subject = "SCM - Purchase Order Increase Request"
.Body = xMailBody
.display 'use .Send or .display
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
I want to be able to also send out :-
Sub MailOrder16()
'By Martin Nesbitt @ MJNSystems
Dim OutApp As Object
Dim OutMail As Object
Dim MailBody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
MailBody = "Village/Sceme - " & [$c10] & vbNewLine & vbNewLine & "Work Request " & [$D16] & vbNewLine & vbNewLine & _
GetUserName & " has requested you attend " & [c16] & vbNewLine & vbNewLine & "UPRN I.D. - " & [B16] & vbNewLine & vbNewLine & _
" The triaged repair description is - " & [AC16] & vbNewLine & vbNewLine & "The Job Priority has been set as " & [t16] & " which is " & [bn16] & " response" & vbNewLine & vbNewLine & _
"Your Initial Po Value has been set at - £" & [$ad16] & vbNewLine & vbNewLine & _
"Please confirm receipt of this Require with Engineer ETA to Inbox repairrequest@extracare.org.uk"
On Error Resume Next
With OutMail
.To = [Bq16]
.CC = "repairrequest@extracare.org.uk"
.BCC = ""
.Subject = "Request to attend Repair Request"
.Body = MailBody
.display 'use .Send or .display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
I get the message
The Syntax of this name isn't correct.
Verify that the name:
-Starts with a letter or Underscore(_)
_Doesn't include a space or character that isnt allowed
_Doesn't conflict with an existing name in the workbook.
I have used the formula =if(M16<>"Select Contactor",MailOrder16(),"")
can anybody offer help
Thanks