Hi all,
(I apologise if this thread is out-of-topic)
I need some ideas for my project.

I have to develop a web application for some users to approve some documents.
The problem I have is that I can't give these people a login account (due to my project requirement).

I have to send email(with the link to each particular form) to these people. Each webpage has more than 5 names.
I don't know how to identify the individuals and only allow them to approve against their names only.

Does anyone has any suggestions? Please help.

Send a verification code in the link which will identify them provide you maintain a record of all verification codes, once it is clicked it cannot used by anyone. You might have to maintain a table with some basic user info to whom you are emailing the form for approval.

Thank you verr much.
I'm stuck for days and I love this idea!

Let me know if you need some help we can work out something.

Thanks !!
Honestly, I know nothing about verficiation code.
I've googled on it and found some code regarding generating of verification code.

May I ask if I am correct like this?

My database table
user(userId, name, email)
project(projectId, userId, status, reason, v_code)

*status = approved/rejected.

My problem now is I don't know how to generate the URL (with the v_code) in the email.

Next, how can I "disable" the link after the user has approve/reject the documents?

By the way, I'm building a web app in a Intranet environment.

Thanks for your help. =)

Do not append it in the url, rather direct them to a verification page which has a text box, where user would have to copy and paste the verification code from email.

Hi, thanks for your reply, just to clarify something..

approvalParties (APId, projectId, name, designation, email, watcherEmail)

ver_code (v_code, apid)

am I right?

Hi, thanks for your reply, just to clarify something..

approvalParties (APId, projectId, name, designation, email, watcherEmail)

ver_code (v_code, apid)

am I right?

You said this requests can goto only designated people. So is anyone allocated to a particlar project? Can the same request goto multiple people? If then you might have to add user_id in ver_code

yeah. But these people don't have a userid , so i actually gave them an id in the table approvalParties.

Erm, then I can use the apid to identify them, am i right to say so?

yeah. But these people don't have a userid , so i actually gave them an id in the table approvalParties.

Erm, then I can use the apid to identify them, am i right to say so?

Yes, if app id is only for one user then you can.

Hi and thanks for your reply,

I found the method of generating numbers. It's working... But how can I improve it so that the code are not repeated as v_code is my primary key in my database.

the method is as follows:

//Generate v_code
private String generateVCode()
{        
    char[] normalChars = "qwertyuiopasdfghjklzxcvbnm1234567890".ToCharArray();

    string code = string.Empty;

    for (int i = 0; i < 20; i++)
    {
        char n = ' ';

        n = normalChars[GetRandomNumber(normalChars.Length - 1)];

        if (i % 2 == 0)
            code += n.ToString().ToUpper();

        else
            code += n;
    }
    return code;
}

//Get Random Number
public static int GetRandomNumber(int maxvalue)
{
    System.Security.Cryptography.RandomNumberGenerator random =

    System.Security.Cryptography.RandomNumberGenerator.Create();

    byte[] r = new byte[1];

    random.GetBytes(r);

    double val = (double)r[0] / byte.MaxValue;

    int i = (int)Math.Round(val * maxvalue, 0);

    return i;
}

Thank you in advance.

You can check it against the Database, if it already exists then call the same routine to generate next randomn no.

Cool, I understand already. Thanks..
Erm, Now I have an error with my email.

I have 2 recipents, both vercode and apid in the database are different.

however, both the recipents receive the same vercode. the first recipents receive the second recipent's ver_code(different from database).

String body = "<html><body>Hi, <br><br>&nbsp;&nbsp;&nbsp; 
             "<br>&nbsp;&nbsp;&nbsp;<a href='<link>/'> VDAS </a> <br>&nbsp;&nbsp;&nbsp;Your Verification code is : <b>";

        String footer = "</b><br>&nbsp;&nbsp;&nbsp;Thank You!" +
            "<br><br>Regards, <br>Team</body></html>";

        VerCode vc = new VerCode();

        if (!txtEmail1.Text.Equals("")) 
        {
            String v_code = generateVCode();
            vc = new VerCode(v_code,"1",projectID);            
            VerCodeDAO.addVCode(vc);

            msgMail.Body = body + v_code + footer;

            MailAddress to1 = new MailAddress(txtEmail1.Text);

            if (!txtWatcherEmail1.Text.Equals(""))
            {
                MailAddress cc1 = new MailAddress(txtWatcherEmail1.Text);
                msgMail.CC.Add(cc1);
            }
            msgMail.To.Add(to1);


        }

        if (!txtEmail2.Text.Equals(""))
        {
            String v_code = generateVCode();
            vc = new VerCode(v_code, "2", projectID);
            VerCodeDAO.addVCode(vc);

            MailAddress to2 = new MailAddress(txtEmail2.Text);

            if (!txtWatcherEmail2.Text.Equals(""))
            {
                MailAddress cc2 = new MailAddress(txtWatcherEmail2.Text);
                msgMail.CC.Add(cc2);
            }
            msgMail.To.Add(to2);
            msgMail.Body = body + v_code + footer;

        }

       smtp.Send(msgMail);

I tried and put smtp.Send(msgMail); into each if statement but it's worst.

I apologise for troubling you but please advice. Thanks a Million. By the way, I find that it's not good to use if statements for checking of each txtbox (null or not) because I've 5 textboxes.

Other than using switch is there any methods for me to use? I thought of using for loop. is it possible. if so, can you please give me some hints/tips on the coding ...

First debug and see what values are you getting for String v_code = generateVCode(); for each each call.
Then try using diff. mail objects to send mails to diff. people. In the above example you are trying to send the same mail to diff. user.

ok, I got the problem,
In the database you might be getting diff. verification code but when you send in email it is coming same, right?
And the reason is because you are using the same mail object and same v_code variable. You have to use diff. mailobject instances for diff. values.

Cool. I got it already. It's working perfectly. Thanks man~
So now I can use the v_code, from here it's similar with login right?

get the v_code from the textbox, check who is the user or valid v_code then show the output?
am i right?

by the way, erm, there's no other options then if-else statements/switch??

sorry.

Switch is faster than using "if". Also i think you are in the right direction with the login.

Let me know how it goes.

Thanks for your help... =)
I will keep you update... Hopefully, I don't need to trouble you so much anymore... =)

Hi, I'm working on Switch right now.
I saw switch statements online.

Switch (variable)
{
   case 1: //do something
   case 2: //do something else
   break;
}

but I don't know what variable I need for my case. Er can you please help?
I'm trying to use switch instead of if-else...

if (!txtEmail1.Text.Equals("")) 
        {
            msgMail1.From = new MailAddress(txtPCEmail.Text);
            if (!txtBackupEmail.Text.Equals(""))
            {
                msgMail1.CC.Add(new MailAddress(txtBackupEmail.Text));
            }

            msgMail1.Subject = "TEST EMAIL for VR Documents (EndPack) - " + projectID;

            msgMail1.IsBodyHtml = true;

            String v_code = generateVCode();
            vc = new VerCode(v_code,"1",projectID);            
            VerCodeDAO.addVCode(vc);

            msgMail1.Body = body + v_code + footer;

            MailAddress to1 = new MailAddress(txtEmail1.Text);

            if (!txtWatcherEmail1.Text.Equals(""))
            {
                MailAddress cc1 = new MailAddress(txtWatcherEmail1.Text);
                msgMail1.CC.Add(cc1);
            }
            msgMail1.To.Add(to1);
          
            
        }

        if (!txtEmail2.Text.Equals(""))
        {
            msgMail2.From = new MailAddress(txtPCEmail.Text);
            if (!txtBackupEmail.Text.Equals(""))
            {
                msgMail2.CC.Add(new MailAddress(txtBackupEmail.Text));
            }

            msgMail2.Subject = "TEST EMAIL for VR Documents (EndPack) - " + projectID;

            msgMail2.IsBodyHtml = true;

            String v_code = generateVCode();
            vc = new VerCode(v_code, "2", projectID);
            VerCodeDAO.addVCode(vc);

            MailAddress to2 = new MailAddress(txtEmail2.Text);

            if (!txtWatcherEmail2.Text.Equals(""))
            {
                MailAddress cc2 = new MailAddress(txtWatcherEmail2.Text);
                msgMail2.CC.Add(cc2);
            }
            msgMail2.To.Add(to2);
            msgMail2.Body = body + v_code + footer;
          
        }

As you are comparing two diff. text objects it is good to go with If.

I see. Thanks.
I think I will not edit about that anymore.

Yes, you are good to go.

Yeah, Thanks for your help all this while

No Problem.

Hey, Hihi,
The verification code is done!
It's working perfectly.
Thanks for your help.

Now I have another problem.

I need to send reminder emails to approval parties if they do not respond within 3 days upon submission. How can I do that? I know the methods.. But I don't know how to call the methods, like running "live" 24/7.

I thought of calling the methods when the admins login into the system, but I don't think they will login daily ... So is there any method to let it run daily?

Erm, any advices?
Thanks.

In short, it's like automatic send reminder emails.

Sorry if I am confusing anyone...

I've found something.
Is it console application , windows scheduler?

Erm, then I would have two applications?
Sorry, I'm really confused and have no idea.

Appreciate your help.
Thanks in advance.

You can write a small console app or windows app and schedule it using windows scheduler.

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.