?
Solved

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

Posted on 2011-10-08
7
Medium Priority
?
1,250 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:PianoMover
  • 3
  • 3
7 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 36936066
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1500 total points
ID: 36936115
>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
 

Author Comment

by:PianoMover
ID: 36936342
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36941642
>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
 

Author Comment

by:PianoMover
ID: 36941674
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36941756
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
 

Author Closing Comment

by:PianoMover
ID: 36941765
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
With its various features, Office 365 can not only help you with your day-to-day business tasks, it can also do wonders for your marketing campaign.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question