3

Just writing a simple mailer using asp mvc mailer I have gone through the tutorial and the email is being send. However i cannot seem to include absolute Urls. In the example they use a Html helper from System.Web.Mvc.UrlHelper

The absolute should be written like so

<a href="@Url.Abs(@Url.Action("Index","Home"))">Linkage</a>

But i get the error

'System.Web.Mvc.UrlHelper' does not contain a definition for 'Abs' and no extension method 'Abs' accepting a first argument of type 'System.Web.Mvc.UrlHelper' could be found (are you missing a using directive or an assembly reference?)

From the searching i have done everyone seems to add it very nonchalant, as if "you just add the thing."

Any suggestions?

Community
  • 1
  • 1
  • 1
    Well, as you can see here http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper(v=vs.118).aspx there is no such method. It's probably custom. – Yevgeniy.Chernobrivets Apr 24 '14 at 08:04
  • Thanks Its weird that they dont mention that it is a custom helper.All the links i have been to, that explain the mailer setup, they all use the @Url.Abs like its apart of System.Web –  Apr 24 '14 at 08:08
  • It is not in default implementation of urlhelper class. But maybe when you add mailer namespace it contains extension methods for it. – Yevgeniy.Chernobrivets Apr 24 '14 at 08:10
  • Can you please provide any of those links? – Yevgeniy.Chernobrivets Apr 24 '14 at 08:12
  • http://www.bgsoftfactory.net/5-steps-to-send-email-with-mvcmailer-from-an-mvc-4-0-application/, https://github.com/smsohan/MvcMailer/wiki/MvcMailer-Step-by-Step-Guide, –  Apr 24 '14 at 08:14
  • I do see it though. In the Mvc.Mailer under UrlHelperExtentions as Abs(this System.Web.Mvc.Urlhelper,string) in the object browser –  Apr 24 '14 at 08:15
  • Boom!! I got it. I needed to add a @using MvcMailer to the View (even though it is in the web.config >< ).Thanks for bouncing off ideas! –  Apr 24 '14 at 08:27

1 Answers1

5

You have to add:

@using Mvc.Mailer;

to your Mailer view

Matthew Belk
  • 1,904
  • 2
  • 20
  • 28