Recipients.Add generates Runtime error '287': Application-defined or object-defined error

后端 未结 2 1850
情书的邮戳
情书的邮戳 2021-01-17 05:30

I am testing how to send an e-mail. I have copied the code below from the help files:

Sub CreateHTMLMail()
\'Creates a new e-mail item and modifies its prope         


        
相关标签:
2条回答
  • 2021-01-17 05:50

    Edit:
    As the OP states in his comment to my original answer, changing his code to

    .Recipients.To = "abc@xyz.com" 
    

    solved his problem. I leave my original answer below, because someone may learn from the mistake I made, pointed out by divo ;-)


    Original answer (careful, this is wrong!):

    Try enclosing the parameters passed to the Add method with parentheses:
    .Recipients.Add ("xyz@abc.com")

    0 讨论(0)
  • 2021-01-17 05:52

    Try this:

       toString = "me@email.com;you@email.com;them@email.com"
    
        With OutMail
            .To = toString
            .Subject = "Hello Friends"
            .Body = "Here is the email body"
            .Send
        End With
    

    This of course works with multiple recipients. For a single recipient, just do this:

    toString = "oneguy@gmail.com"
    

    And don't forget the .Send to actually make your email send.

    0 讨论(0)
提交回复
热议问题