1
Public Async Function Register(model As RegisterViewModel) As Task(Of ActionResult)
        If ModelState.IsValid Then
            Dim user = New ApplicationUser() With {
                .UserName = model.Email,
                .Email = model.Email
            }
            Dim result = Await UserManager.CreateAsync(user, model.Password)
            If result.Succeeded Then
                Await SignInManager.SignInAsync(user, isPersistent:=False, rememberBrowser:=False)

                ' For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                ' Send an email with this link
                Dim code = Await UserManager.GenerateEmailConfirmationTokenAsync(user.Id)
                Dim callbackUrl = Url.Action("ConfirmEmail", "Account", New With {.userId = user.Id, .code = code}, protocol:=Request.Url.Scheme)
                UserManager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=""" & callbackUrl & """>here</a>")

                Return RedirectToAction("Index", "Home")
            End If
            AddErrors(result)
        End If

        ' If we got this far, something failed, redisplay form
        Return View(model)
    End Function

This is the standard registration code

Now I've setup my SMTP in web.config and I even tested the details on other services/email programs and it worked

  <system.net>
    <mailSettings>
      <smtp from="*@ziggo.nl" deliveryMethod="Network">
        <network defaultCredentials="true" host="smtp.ziggo.nl" port="587" userName="*@ziggo.nl" password="*" enableSsl="true" />
      </smtp>
    </mailSettings>
  </system.net>

Now this is the smtp settings I used. I had hidden my personal details with a * but I'm wondering why mail didn't get send with the UserManager.SendEmail

OlehZiniak
  • 933
  • 1
  • 13
  • 29
Glenn
  • 33
  • 6
  • Did you setup smtp on the IIS server? If you're using a dev machine (with no win server edition) you could use something like smtp4dev to view the outgoing email. – Esselans Dec 15 '15 at 01:10
  • just fixed it by directcasting the smtp part of the configurationmanager and grabbing the variables from it – Glenn Dec 15 '15 at 02:37
  • Here is your details answer. Although it is using c# code https://stackoverflow.com/a/45789677/3835843 – Arif Aug 21 '17 at 05:39

0 Answers0