Sending email in ASP.NET webform on behalf of user completing form

I am trying to figure out the best way to do something that I believe should be simple and is a really common item on websites, but I am failing miserable to impliement the way I think it should work.  On most websites that have a question or message form to fill in, you have a minimum of 3 standard textboxes to fill in: Your Name, Your email Address, Your message.  Now I am making an assumption here that these web forms send an email to the website provider email server in question with the Name & email address in the email from field, the message in the body of the email and the rest is configured by the website form by some preset settings.

I've written this exact procedure in vb asp.net and had it working sending emails to my exchange 2007 server at my office.  Then all I have to do is hit the reply button when I get the email and answer the question.

Now for the problem: I am trying to remove my exchange 2007 server because I don't have the time to maintain the server myself anymore and want to outsource my email service.  I have a google apps for domain account and an office 365 account setup that I am currently experimenting with.  I have modified the code to send to both of these accounts and got them both to receive a test email.  Here's the catch:  The only way it works, is if the from email address is the same as the account I am sending it too, which is basically me.  So I can receive an email from the website, but the from address is always the same (me) and I can never reply to anyones email, because the reply comes back to me since I am now the sender. If I try to send as the user from the input box on the form the email gets rejected from Gmail & Office 365 as a permissions problem (don't have rights to send email on behalf of that email address/user).  Talking with Office 365 tech support this is probably for spam reasons.  Frustrating.  Now I have a wordpress website using cform and it will send an email to the gmail account without a problem (haven't tried office 365 yet) showing the email coming from the user input box, exactly the way I am trying to do in asp.net.  Now I don't want to use wordpress for this function, I need an asp.net website so I can take advantage of some vb code I want to use on the form.  The wordpress cform has obviously found a way around this problem, but I cannot find similar solution in asp.net, remembering that I am trying to down the number of computers/servers that I am maintaining.

I have to believe that someone has run into this same problem out there and that there are lots of asp.net websites doing what I am trying to accomplish.  I really don't want to keep runing this exchange server, but will if I have too.  I believe the key is in the asp.net code I am using, because I didn't do anything special with the wordpress site to make it work with gmail.  Any suggestions/solutions on how to solve my problem?
PianoMoverAsked:
Who is Participating?
 
CodeCruiserCommented:
>Now I am making an assumption here that these web forms send an email to the website provider email server

No they dont. They cant without the password. You can send the email from your own address but use that person's name in the From. You can also set the ReplyTo so that if the end user wants to reply directly, they can.
0
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
PianoMoverAuthor Commented:
Thanks emoreau, but I've already read this article prior to posting question and if I follow correctly it is for in house items only (all in one printers).  It also means I still need to have a basic email server on site open to the internet for my website to go through which is what I am trying to get away from.

CodeCruiser:
1. asp.net webform hosted on a 3rd party provider and I am wanting to shoot email from it to an office 365 account which is exchange 2010 server.  

2. I didn't follow what you meant in the first half of the second paragraph, but I tried the replyto option like you suggested and it basically or half accomplishes what I am looking for.  Now here is the spoiled person talking.  Using the replyto option like you suggested functionally works for my main concern, but all the emails coming in now show in my inbox as coming from me or another account I might designate it as instead of the person that was sending it.  I can technically live with it, but I am spoiled from my previous setup where it shows it coming from the user in question who sent it.  This was handy because I could sort by send from in outlook and see all emails from this individual in date received order.  I could put their name in the subject line, but is their any way to put them in the from address as well.  My wordpress website does this and I am wondering whether there is a way in asp.net too?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
CodeCruiserCommented:
>You can send the email from your own address but use that person's name in the From

What I meant was that you can set the from email address and name of the message itself to the person but use the email server and credentials of your own (message.from vs smtpclient.credentials)
0
 
PianoMoverAuthor Commented:
Code Cruiser:

I've tried putting that person's name in the from field while using my credentials to log into the server, but the email server rejects the email basically saying it is not a valid from address in office 365 and gmail just overwrites the from address with the credentials email address.

The odd part is if I try wordpress and use it's cform to send an email, it works fine with gmail and doesn't even require the credentials.  It is like it is using a different method for sending the email.
0
 
CodeCruiserCommented:
They use the "Send on behalf of" feature which allows another user to send email on behalf of someone else. They probably send using their own server but have configured it to allow other users (the one filling the form) to send the email.
0
 
PianoMoverAuthor Commented:
Thanks CodeCruiser.  I'm going to use the ReplyTo command to get around my current problem.  It's not the answer I was hoping for, but it definitely will get the job done.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.