locked
Argument not optional RRS feed

  • Question

  • Private Sub Worksheet_Change(ByVal Target As Range)
    Dim s1, s2, s3, s4 As String
    If Not Intersect(Target, Range("e7:e7000")) Is Nothing Then
        If Target.Cells.Count = 1 Then
        s1 = Target.Offset(0, -2).Value
        s2 = Target.Value
        s3 = "The following line reference was updated at " & Now & " By user " & NetworkUserName() & "<br>" & "Ref: " & s1 & "<br>" & "Stock Code: " & s2
        Sendmail "Stock Delinquency Register", s3, "user emails.."
        End If
    End If
    End Sub

    Private Sub Sendmail(ByVal subject As String, ByVal body As String, ByVal rcpt As String, ByVal sender As String)

    Set objEmail = CreateObject("CDO.Message")

    objEmail.from = sender
    objEmail.To = rcpt
    objEmail.subject = subject
    objEmail.HTMLBody = body
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "hac-exs"
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 499
    objEmail.Configuration.Fields.Update

    objEmail.Fields.Item("urn:schemas:mailheader:X-MSMail-Priority") = "High" ' For Outlook 2003
    objEmail.Fields.Item("urn:schemas:mailheader:X-Priority") = 2 ' For Outlook 2003 also
    objEmail.Fields.Item("urn:schemas:httpmail:importance") = 2 ' For Outlook Express
    objEmail.Fields.Update


    m objEmail.Send

    End Sub

    Any ideas why i got error message "Argument not Optional" problem with Sendmail in s3

    Wednesday, April 25, 2018 2:17 PM

Answers

  • Private Sub Sendmail(ByVal subject As String, ByVal body As String, ByVal rcpt As String, ByVal sender As String)
    As per above, SendMail needs 4 Argument.

    In below call 3 argument used. 4th argument required.

    3rd argument mentioned as "user emai..". Check if it acceptable as rcpt string.

    Sendmail "Stock Delinquency Register", s3, "user emails.."


    Best Regards, Asadulla Javed

    • Marked as answer by Pawek2chh Thursday, April 26, 2018 10:28 AM
    Thursday, April 26, 2018 8:46 AM
    Answerer