Mask Sender's/Recipient's Email Address

Last post 05-16-2008 4:04 PM by yonahw. 11 replies.

Sort Posts:

  • Mask Sender's/Recipient's Email Address

    05-14-2008, 7:15 PM
    • Loading...
    • gulrnpink
    • Joined on 11-26-2007, 1:00 PM
    • Posts 64

    First of all, I apologize if I posted on the wrong forum (Couldn't find one specific to my requirement).

    Anyway, I created a form that allows users to send email notifications to other users in our domain.  What I intended to do is to mask the sender's and recipient's email addresses upon sending mail.  I was looking for related posts but didn't find any.  Below is an example of my requirement:

    In the actual email message, it should look something similar to this:

    Subject: Notification

    From: MyEmployer 

    To: MyEmployee

    Body: You have just received a notification!

  • Re: Mask Sender's/Recipient's Email Address

    05-14-2008, 10:00 PM
    • Loading...
    • yonahw
    • Joined on 06-07-2007, 8:02 AM
    • Posts 68

     I don't know what version of .net you are using but from 2.0 on there is a system.net.mail.

    You can use this and create a mailaddress object which is your email address.  One of the constructors for the mailaddress object takes a display name as the second parameter which should meet your requirements.

  • Re: Mask Sender's/Recipient's Email Address

    05-15-2008, 12:42 AM
    • Loading...
    • gulrnpink
    • Joined on 11-26-2007, 1:00 PM
    • Posts 64

    Hi yonahw, thanks for your input.  I was able to declare the display names for both sender and recipient.  Sorry if this sounds dumb but I've never really worked with System.Net.Mail before.. How do I show the displayname on the message now?  The message still shows the sender's and recipient's email addresses.

  • Re: Mask Sender's/Recipient's Email Address

    05-15-2008, 9:04 PM
    • Loading...
    • yonahw
    • Joined on 06-07-2007, 8:02 AM
    • Posts 68

     not at all.

    Please show me the bit of code you are using here and maybe I can glean some more from this.

  • Re: Mask Sender's/Recipient's Email Address

    05-16-2008, 1:49 AM
    • Loading...
    • gulrnpink
    • Joined on 11-26-2007, 1:00 PM
    • Posts 64

    Hi yonahw,

    Here's a snippet of the code I use:

    ...

    MailMessage msg = new MailMessage();

    msg.To.Add(new MailAddress(userEmail, ConfigurationSettings.AppSettings["mailToHdr"].ToString()));

    msg.From = new MailAddress(ConfigurationSettings.AppSettings["mailFromAdd"].ToString(), ConfigurationSettings.AppSettings["mailFromHdr"].ToString());

    msg.Subject = objTitle;

    msg.IsBodyHtml =
    true; SmtpClient client = new SmtpClient();

    client.Host = mail;

    client.Send(msg);

    ...

    The mail gets delivered with no error.  The only thing is the email addresses still don't change to displayname specified.

  • Re: Mask Sender's/Recipient's Email Address

    05-16-2008, 6:07 AM
    • Loading...
    • yonahw
    • Joined on 06-07-2007, 8:02 AM
    • Posts 68

     Can you show the definitions of "mailToHdr" and "mailFromHdr"?

    Also when you say  "the email addresses don't change" do you mean that the displayname is not being displayed at all or that it is being displayed in addition to the email address?

  • Re: Mask Sender's/Recipient's Email Address

    05-16-2008, 6:33 AM
    • Loading...
    • gulrnpink
    • Joined on 11-26-2007, 1:00 PM
    • Posts 64

    "mailToHdr" and "mailFromHdr" both have string values ("Test To", "Test From") 

    For the "From" field, both email address and displayname show up on the email while the "To" field only shows the email address.

     

  • Re: Mask Sender's/Recipient's Email Address

    05-16-2008, 6:40 AM
    • Loading...
    • paindaasp
    • Joined on 12-19-2007, 12:47 PM
    • Exit 3
    • Posts 110

    You can put any valid email address in the From address by:

    msg.From = new MailAddress("MyEmployer","MyEmployer@emailadd.com");

  • Re: Mask Sender's/Recipient's Email Address

    05-16-2008, 6:47 AM
    • Loading...
    • yonahw
    • Joined on 06-07-2007, 8:02 AM
    • Posts 68

     In my test case I get the email listed, in Outlook, with the display name only as from.

    When viewing the actual email the from shows both display name and email address while the to field just shows display name.

    This seems to me to be the standard way such things are handled.

    How would  you prefer it to appear?

  • Re: Mask Sender's/Recipient's Email Address

    05-16-2008, 10:42 AM
    • Loading...
    • gulrnpink
    • Joined on 11-26-2007, 1:00 PM
    • Posts 64

    I am getting the same thing where in the inbox listing only the displayname is displayed as from and when the message is opened the displayname together with the email add in brackets are shown as from and the to field just displays the email add.

    What I want to do is to mask both the recipient's and sender's email adds.  Ultimately, it's the sender's address that I want to mask so that the reciepient won't be able to reply back to the sender. But if possible, I prefer to mask both.

  • Re: Mask Sender's/Recipient's Email Address

    05-16-2008, 10:43 AM
    • Loading...
    • gulrnpink
    • Joined on 11-26-2007, 1:00 PM
    • Posts 64

    paindaasp,

    That is actually how I declared my "msg.From" although the email address goes before the displayname.  It doesn't work for me.

  • Re: Mask Sender's/Recipient's Email Address

    05-16-2008, 4:04 PM
    • Loading...
    • yonahw
    • Joined on 06-07-2007, 8:02 AM
    • Posts 68

    I don't know that you can actually do what you want to do.

    The from address does not need to be a real address so you could do something like make the from address noreply@domain.com and it would not actually go anywhere.  I would suggest having some line in the actual message that states the email address can not be replied to.

    You can also control the reply to address.

Page 1 of 1 (12 items)