locked
How to Set Email Programming RRS feed

  • Question

  • User910349441 posted

    Hi there, I'm developing a site using Starter Site template and i want my site to be included with email setting for example on how to create an email through my site. e.g. (info@mysite.com)

    Thank  you for your usual cooperation.

    Sunday, September 20, 2015 2:54 AM

Answers

  • User1313602441 posted
    Am confused a bit.
    Are you looking for a way to create a custom email only?
    Or are you looking for a way send email locally for devt purpose?
    If the first is your case then you should know when you host your website, your webhosting company could give you email capabilities. Thus if you create a website (e.g mywebsite.com), and you setup your Smtp Server with your web host, then you will get a custom email (e.g anybody@mywebsite.com).
    But since you're still testing with your devt server on WebMatrix, you could follow the procedure I gave earlier. It serves the same purpose.
    And do note that the "WebMail.From" variable could contain any random email, but with a valid format. Example:
    WebMail.From = "anybody@mywebsite.com"
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 20, 2015 3:32 PM

All replies

  • User1313602441 posted
    To do that you'll need to use the WebMail helper.
    But first you'll need to set it up with your server (either devt or production server).
    Put this code in your _AppStart.cshtml:
    @{
    WebMail.SmtpServer = "your-smtp-server";
    WebMail.SmtpPort = 25;
    WebMail.EnableSsl = false;
    WebMail.UserName = "your username";
    WebMail.Password = "your password";
    WebMail.From = "user@domain.com";
    }

    Note: In order to send email on your site, you need to setup your SMTP configuration. Your web host can provide with this.
    But if you want to test sending emails on WebMatrix (i.e your devt server), you will need to add some settings to your Web.config file.
    Sunday, September 20, 2015 6:47 AM
  • User910349441 posted
    I'm working with Microsoft WebMatrix, and i want to know how to create an email with my development site that has not been published yet.
    What type of technology or tool can i use to create an email not to send an email.
    Thanks
    Sunday, September 20, 2015 12:22 PM
  • User325035487 posted

    Are you talking about a Mail Composing Interface?

    You could make a simple form like mentioned here http://www.asp.net/web-pages/overview/getting-started/11-adding-email-to-your-web-site

    Sunday, September 20, 2015 2:24 PM
  • User1313602441 posted
    In order to do this Ishaqm, you'll need to use the "pickup directory" option.
    Follow the steps below I got reading Mike Brind's book:
    1). Open your web.config file and add the following to it just before the closing </configuration> tag:
    <system.net>
    <mailSettings>
    <smtp deliveryMethod="SpecifiedPickupDirectory">
    <specifiedPickupDirectory pickupDirectoryLocation="C:\Mail\" />
    </smtp>
    </mailSettings>
    </system.net>
    2). In the above, all emails sent will be stored in a folder called "Mail" on your computer's hard drive. You could decide to name the folder any other name, or place it anywhere. But the folder you specify must exist before attempting to send a mail.
    3). Go to your _AppStart file and use the WebMail code I posted earlier. But change the value of the SmtpServer, and use this instead:
    WebMail.SmtpServer = "127.0.0.1";
    4). Use the following code on any page you want to use to send email:
    WebMail.Send(
    to: Request["email"],
    subject: "Your email subject",
    body: "the content of your mail",
    isBodyHtml: false; //optional. this determines if the message body is HTML or plain text.

    );
    And that's all you need.
    Goodluck!
    Sunday, September 20, 2015 3:04 PM
  • User1313602441 posted
    Am confused a bit.
    Are you looking for a way to create a custom email only?
    Or are you looking for a way send email locally for devt purpose?
    If the first is your case then you should know when you host your website, your webhosting company could give you email capabilities. Thus if you create a website (e.g mywebsite.com), and you setup your Smtp Server with your web host, then you will get a custom email (e.g anybody@mywebsite.com).
    But since you're still testing with your devt server on WebMatrix, you could follow the procedure I gave earlier. It serves the same purpose.
    And do note that the "WebMail.From" variable could contain any random email, but with a valid format. Example:
    WebMail.From = "anybody@mywebsite.com"
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 20, 2015 3:32 PM
  • User910349441 posted
    Thanks a lot Abubad, that's what i meant, I'm looking for a way to create a custom email only, so i should wait till i host my website.
    Thank you for your response and others in general.
    Sunday, September 20, 2015 4:36 PM
  • User379720387 posted

    Nope.

    You can send email and test your code directly from a local machine, provided it is set up to send email.

    Monday, September 21, 2015 8:07 AM
  • User910349441 posted

    Ok, Thanks.

    Tuesday, September 22, 2015 6:39 PM