The original documentation exists here.
I have already converted the controller action:
Imports ActionMailer.Net.Mvc
Public Class EmailController
Inherits MailerBase
Public Function VerificationEmail(ByVal model As RegisterModel) As EmailResult
[To].Add(model.Email)
From = "me@my.org"
Subject = "Thanks for registering with us!"
Return Email("VerificationModel", model)
End Function
End Class
And, the view (EmailVerification.html.vbhtml):
@modelType GemcoBlog.RegisterModel
@Code
Layout = Nothing
End code
Welcome to My Cool Site, @Model.UserName
We need you to verify your email. Click this nifty link to get verified!
@Html.ActionLink("Verify", "Account", New With {.code = Model.Email})
Thanks!
But, how do I convert this C# code to call the function from within my Register method to VB?
new MailController().VerificationEmail(newUser).Deliver();
I haven’t found anything on the internet describing how to do this in VB, so maybe this post will be helpful for those looking.
As a side note: Could someone please explain to me this syntax [To].Add(model.Email)? I haven’t seen that before. Thanks.
or if you prefer one liners:
Tois a reserved word in VB. Wrapping it in square brackets ensures that you are not clashing with this reserved keyword.The equivalent in C# is the
@keyword: