Hello
I am currently designing an internal ordering system for IT equipment.
I am designing it in ASP.NET (vb) using Visual Studio 2003 and using
Microsoft SQL Server
I have got the system to add the order into the database and assign it
a unique ID ("EITReqCode "), and made it e-mail the it purchaser via
SMTP automatically with a link to the "Authorisat ion" page where they
are to cost and authorise the IT request. What i want to be able to do
now, is add to that link the unique ID of the order just submitted so
when the purchaser opens the e-mail they will see the order which was
submitted relating to that specific email.
I am quite new to this and quite impressed with what i have achieved
single-handidly but now require some assistance.
Can anyone help me and advise me how to perform this function.
If you want to see some of my scripting already i will post it up.
Many thanks in advance.
James O'Neill
BSc (Hons) Business Information Systems Management 8 1539
Jimbo,
Are you using SQLMail or the System.Web.Mail namespace to send the
email?
Gary
Jimbo wrote: Hello
I am currently designing an internal ordering system for IT equipment.
I am designing it in ASP.NET (vb) using Visual Studio 2003 and using Microsoft SQL Server
I have got the system to add the order into the database and assign it a unique ID ("EITReqCode "), and made it e-mail the it purchaser via SMTP automatically with a link to the "Authorisat ion" page where they are to cost and authorise the IT request. What i want to be able to do now, is add to that link the unique ID of the order just submitted so when the purchaser opens the e-mail they will see the order which was submitted relating to that specific email.
I am quite new to this and quite impressed with what i have achieved single-handidly but now require some assistance.
Can anyone help me and advise me how to perform this function.
If you want to see some of my scripting already i will post it up.
Many thanks in advance.
James O'Neill BSc (Hons) Business Information Systems Management
I am using the System.Web.Mail namespace within asp.net, and using
SurgeMail as a testing SMTP server (on local machine).
Code im using is below (with alterations for confidentiality )
Sub BTNSubmit_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles BTNSubmit.Click
'Create an instance of the MailMessage class
Dim objMM As New MailMessage
'Set the properties
objMM.To = "it************ @companyname.co .uk"
objMM.From = "it*********@co mpany.co.uk"
' Send the email in text format
objMM.BodyForma t = MailFormat.Text
'(to send HTML format, change MailFormat.Text to
MailFormat.Html )
'Set the priority - options are High, Low, and Normal
objMM.Priority = MailPriority.No rmal
' Set the subject
objMM.Subject = "eIT Request"
'i want to be able to add the request number on the subject
' Set the body - use VbCrLf to insert a carriage return
objMM.Body = "A new IT request was submitted at " +
DateTime.Now + " please click below to review and authorise" & vbCrLf &
_
"http://rcsukbaswks0099/webapplication2/authorisation.a spx"
SmtpMail.SmtpSe rver = "127.0.0.1"
SmtpMail.Send(o bjMM)
Response.Redire ct("confirmed.a spx")
======end of code=========== =
Gary wrote: Jimbo,
Are you using SQLMail or the System.Web.Mail namespace to send the email?
Gary
the typical approach is to use a querystring in the url of the linek
http://mysite.com/orders/vieworder.aspx? id=<orderid>
then in the code behind you check the Request.QuerySt ring["id"] for the
value passed. try not to make the id sequential, or they are easy to hack
(add one to your number and see someone else order)
-- bruce (sqlwork.com)
"Jimbo" <ji**********@g mail.com> wrote in message
news:11******** *************@x 69g2000cwx.goog legroups.com... Hello
I am currently designing an internal ordering system for IT equipment.
I am designing it in ASP.NET (vb) using Visual Studio 2003 and using Microsoft SQL Server
I have got the system to add the order into the database and assign it a unique ID ("EITReqCode "), and made it e-mail the it purchaser via SMTP automatically with a link to the "Authorisat ion" page where they are to cost and authorise the IT request. What i want to be able to do now, is add to that link the unique ID of the order just submitted so when the purchaser opens the e-mail they will see the order which was submitted relating to that specific email.
I am quite new to this and quite impressed with what i have achieved single-handidly but now require some assistance.
Can anyone help me and advise me how to perform this function.
If you want to see some of my scripting already i will post it up.
Many thanks in advance.
James O'Neill BSc (Hons) Business Information Systems Management
Yea i was thought thats how it should look, but im new to this and am
unsure how to get the id automatically into the url in the email.
Could you use my code then give me an example of what it should look
like.
Where abouts would i put the Request.QuerySt ring["id"] ?
We have looked at the ID, and went with sequential as this link is not
given to any employees, only the IT Co-Ordinator.
We have named the id 'EITReqCode', which is in a table called
'IT_Request'.
Many thanks
bruce barker (sqlwork.com) wrote: the typical approach is to use a querystring in the url of the linek
http://mysite.com/orders/vieworder.aspx? id=<orderid>
then in the code behind you check the Request.QuerySt ring["id"] for the value passed. try not to make the id sequential, or they are easy to hack (add one to your number and see someone else order)
-- bruce (sqlwork.com)
"Jimbo" <ji**********@g mail.com> wrote in message news:11******** *************@x 69g2000cwx.goog legroups.com... Hello
I am currently designing an internal ordering system for IT equipment.
I am designing it in ASP.NET (vb) using Visual Studio 2003 and using Microsoft SQL Server
I have got the system to add the order into the database and assign it a unique ID ("EITReqCode "), and made it e-mail the it purchaser via SMTP automatically with a link to the "Authorisat ion" page where they are to cost and authorise the IT request. What i want to be able to do now, is add to that link the unique ID of the order just submitted so when the purchaser opens the e-mail they will see the order which was submitted relating to that specific email.
I am quite new to this and quite impressed with what i have achieved single-handidly but now require some assistance.
Can anyone help me and advise me how to perform this function.
If you want to see some of my scripting already i will post it up.
Many thanks in advance.
James O'Neill BSc (Hons) Business Information Systems Management
Jim,
What I usually do for emailing is create an XML file and call it, say,
email.config (naming it with a .config extension prevents a user from
pulling it up through the website). In the XML file I define a
template for any emails I want to send. I use something like:
<?xml version="1.0" encoding="utf-8"?>
<email server="smtpser ver">
<template Id="EmailMessag e1">
<from><![CDATA[]]></from>
<cc><![CDATA[]]></cc>
<subject><![CDATA[]]></subject>
<message format="HTML">< ![CDATA[
<html><body>Ema il Message text to [~USER_NAME~]</body></html>]]>
</message>
</template>
</email>
**Take note of the [~USER_NAME~] token in the body. You can create as
many of these nodes as you need, for each type of email you want to
send.
Then I have code like the following to send the actual email:
public class TemplateEmail {
public static void Send(string templatePath, string templateID, string
recipients, Hashtable tokens)
{
//** Load the email configuration template
XmlDocument template = new XmlDocument();
template.Load(t emplatePath);
//** Pull out the template
XPathNavigator nav = template.Docume ntElement.Creat eNavigator();
string smtpServer = nav.GetAttribut e("SMTPServer ", String.Empty);
MailMessage msg = new MailMessage();
//** Process the message elements
XmlNode emailNode =
template.Docume ntElement.Selec tSingleNode(str ing.Format("Tem plate[@Id='{0}']",
templateID));
if (emailNode == null) throw new Exception("Inva lid or missing email
template identifier");
nav = emailNode.Creat eNavigator();
if (!nav.MoveToFir stChild()) throw new Exception("Inva lid email
template - no properties defined");
string token = string.Empty;
while (true)
{
switch (nav.Name)
{
case "From":
msg.From = nav.Value;
break;
case "Cc":
msg.Cc = nav.Value;
break;
case "Bcc":
msg.Bcc = nav.Value;
break;
case "Subject":
//** Perform the subject token replacements
msg.Subject = ReplaceTokens(n av.Value, tokens);
break;
case "Body":
//** Perform the subject token replacements
msg.Body = ReplaceTokens(n av.Value, tokens);
break;
default:
break;
}
if (!nav.MoveToNex t()) break;
}
//** Send the message
msg.To = recipients;
SmtpMail.SmtpSe rver = smtpServer;
SmtpMail.Send(m sg);
}
private static string ReplaceTokens(s tring source, Hashtable tokens)
{
string result = source;
foreach (string key in tokens.Keys)
{
result = result.Replace( key, tokens[key].ToString());
}
return result;
}
}
And then the calling program passes in a hashtable that contains the
tokens to be replaced, along with the value to replace it with. A call
for this case would look like this:
Hashtable properties = new Hashtable();
properties.add( "[~USER_NAME~]", "ggalehouse ");
Email.Send(path _to_email.confi g_file, "EmailMessage1" , properties);
//EmailMessage one is the ID attribute within the email.config file.
I hope this helps. I've used this on numerous projects with great
results.
Thanks,
Gary
Thanks Gary, I will try this out and let you know what happens!
Spent the whole day trying to do this so might give it a break and try
again tomorrow :)
Gary wrote: Jim,
What I usually do for emailing is create an XML file and call it, say, email.config (naming it with a .config extension prevents a user from pulling it up through the website). In the XML file I define a template for any emails I want to send. I use something like:
<?xml version="1.0" encoding="utf-8"?> <email server="smtpser ver"> <template Id="EmailMessag e1"> <from><![CDATA[]]></from> <cc><![CDATA[]]></cc> <subject><![CDATA[]]></subject> <message format="HTML">< ![CDATA[ <html><body>Ema il Message text to [~USER_NAME~]</body></html>]]> </message> </template> </email>
**Take note of the [~USER_NAME~] token in the body. You can create as many of these nodes as you need, for each type of email you want to send.
Then I have code like the following to send the actual email: public class TemplateEmail { public static void Send(string templatePath, string templateID, string recipients, Hashtable tokens) { //** Load the email configuration template XmlDocument template = new XmlDocument(); template.Load(t emplatePath);
//** Pull out the template XPathNavigator nav = template.Docume ntElement.Creat eNavigator(); string smtpServer = nav.GetAttribut e("SMTPServer ", String.Empty); MailMessage msg = new MailMessage();
//** Process the message elements XmlNode emailNode = template.Docume ntElement.Selec tSingleNode(str ing.Format("Tem plate[@Id='{0}']", templateID));
if (emailNode == null) throw new Exception("Inva lid or missing email template identifier"); nav = emailNode.Creat eNavigator(); if (!nav.MoveToFir stChild()) throw new Exception("Inva lid email template - no properties defined");
string token = string.Empty; while (true) { switch (nav.Name) { case "From": msg.From = nav.Value; break; case "Cc": msg.Cc = nav.Value; break; case "Bcc": msg.Bcc = nav.Value; break; case "Subject": //** Perform the subject token replacements msg.Subject = ReplaceTokens(n av.Value, tokens); break; case "Body": //** Perform the subject token replacements msg.Body = ReplaceTokens(n av.Value, tokens); break; default: break; }
if (!nav.MoveToNex t()) break; }
//** Send the message msg.To = recipients; SmtpMail.SmtpSe rver = smtpServer; SmtpMail.Send(m sg); }
private static string ReplaceTokens(s tring source, Hashtable tokens) { string result = source; foreach (string key in tokens.Keys) { result = result.Replace( key, tokens[key].ToString()); }
return result; } }
And then the calling program passes in a hashtable that contains the tokens to be replaced, along with the value to replace it with. A call for this case would look like this: Hashtable properties = new Hashtable(); properties.add( "[~USER_NAME~]", "ggalehouse "); Email.Send(path _to_email.confi g_file, "EmailMessage1" , properties); //EmailMessage one is the ID attribute within the email.config file.
I hope this helps. I've used this on numerous projects with great results.
Thanks, Gary
Gary
Sorry to be an idiot, but could u explain the [~USER_NAME~] function to
me again...
If i want to have different emails set up for various recipients do i
do it here? And do i just repeat the code or repeat the line containing
the [~USER_NAME~] node for this?
Thanks <?xml version="1.0" encoding="utf-8"?> <email server="smtpser ver"> <template Id="EmailMessag e1"> <from><![CDATA[]]></from> <cc><![CDATA[]]></cc> <subject><![CDATA[]]></subject> <message format="HTML">< ![CDATA[ <html><body>Ema il Message text to [~USER_NAME~]</body></html>]]> </message> </template> </email>
**Take note of the [~USER_NAME~] token in the body. You can create as many of these nodes as you need, for each type of email you want to send.
Jimbo wrote:
Thanks Gary, I will try this out and let you know what happens!
Spent the whole day trying to do this so might give it a break and try again tomorrow :)
Gary wrote:
Jim,
What I usually do for emailing is create an XML file and call it, say, email.config (naming it with a .config extension prevents a user from pulling it up through the website). In the XML file I define a template for any emails I want to send. I use something like:
<?xml version="1.0" encoding="utf-8"?> <email server="smtpser ver"> <template Id="EmailMessag e1"> <from><![CDATA[]]></from> <cc><![CDATA[]]></cc> <subject><![CDATA[]]></subject> <message format="HTML">< ![CDATA[ <html><body>Ema il Message text to [~USER_NAME~]</body></html>]]> </message> </template> </email>
**Take note of the [~USER_NAME~] token in the body. You can create as many of these nodes as you need, for each type of email you want to send.
Then I have code like the following to send the actual email: public class TemplateEmail { public static void Send(string templatePath, string templateID, string recipients, Hashtable tokens) { //** Load the email configuration template XmlDocument template = new XmlDocument(); template.Load(t emplatePath);
//** Pull out the template XPathNavigator nav = template.Docume ntElement.Creat eNavigator(); string smtpServer = nav.GetAttribut e("SMTPServer ", String.Empty); MailMessage msg = new MailMessage();
//** Process the message elements XmlNode emailNode = template.Docume ntElement.Selec tSingleNode(str ing.Format("Tem plate[@Id='{0}']", templateID));
if (emailNode == null) throw new Exception("Inva lid or missing email template identifier"); nav = emailNode.Creat eNavigator(); if (!nav.MoveToFir stChild()) throw new Exception("Inva lid email template - no properties defined");
string token = string.Empty; while (true) { switch (nav.Name) { case "From": msg.From = nav.Value; break; case "Cc": msg.Cc = nav.Value; break; case "Bcc": msg.Bcc = nav.Value; break; case "Subject": //** Perform the subject token replacements msg.Subject = ReplaceTokens(n av.Value, tokens); break; case "Body": //** Perform the subject token replacements msg.Body = ReplaceTokens(n av.Value, tokens); break; default: break; }
if (!nav.MoveToNex t()) break; }
//** Send the message msg.To = recipients; SmtpMail.SmtpSe rver = smtpServer; SmtpMail.Send(m sg); }
private static string ReplaceTokens(s tring source, Hashtable tokens) { string result = source; foreach (string key in tokens.Keys) { result = result.Replace( key, tokens[key].ToString()); }
return result; } }
And then the calling program passes in a hashtable that contains the tokens to be replaced, along with the value to replace it with. A call for this case would look like this: Hashtable properties = new Hashtable(); properties.add( "[~USER_NAME~]", "ggalehouse "); Email.Send(path _to_email.confi g_file, "EmailMessage1" , properties); //EmailMessage one is the ID attribute within the email.config file.
I hope this helps. I've used this on numerous projects with great results.
Thanks, Gary
Jim,
I was out of the office today, so I just saw your post. I sorta threw
that code out there without much explanation, so don't worry about not
following all of it.
To make a more specific analogy to your application, you could create
an email template like this:
<?xml version="1.0" encoding="utf-8"?>
<email server="smtpser ver">
<template Id="OrderConfir mation">
<from><![CDATA[em***@domain.co m]]></from>
<cc><![CDATA[]]></cc>
<subject><![CDATA[Order confirmation]]></subject>
<message format="HTML">< ![CDATA[
<html><body>
Order confirmation for: [~ORDER_ID~]
</body></html>]]>
</message>
</template>
</email>
Create the TemplateEmail class (code below) in a class library below
and add a reference to it in your project.
What you would do to send the email when an order is submitted is
create a function like:
Private Sub SendOrderConfir mation(orderID as string)
Dim properties As Hashtable = new Hashtable()
properties.add( "[~ORDER_ID~]", orderID);
//EmailMessage1 one is the ID attribute within the email.config file.
TemplateEmail.S end(path_to_ema il.config_file, "OrderConfirmat ion",
properties);
End Sub
So each time an order was submitted you would call
SendOrderConfir mation with the order identifier, and it would
dynamically replace the [~ORDER_ID~] token with the provided orderID.
Let me know if this isn't clear.
Thanks,
Gary Then I have code like the following to send the actual email: public class TemplateEmail { public static void Send(string templatePath, string templateID, string recipients, Hashtable tokens) { //** Load the email configuration template XmlDocument template = new XmlDocument(); template.Load(t emplatePath);
//** Pull out the template XPathNavigator nav = template.Docume ntElement.Creat eNavigator(); string smtpServer = nav.GetAttribut e("SMTPServer ", String.Empty); MailMessage msg = new MailMessage();
//** Process the message elements XmlNode emailNode = template.Docume ntElement.Selec tSingleNode(str ing.Format("Tem plate[@Id='{0}']", templateID));
if (emailNode == null) throw new Exception("Inva lid or missing email template identifier"); nav = emailNode.Creat eNavigator(); if (!nav.MoveToFir stChild()) throw new Exception("Inva lid email template - no properties defined");
string token = string.Empty; while (true) { switch (nav.Name) { case "From": msg.From = nav.Value; break; case "Cc": msg.Cc = nav.Value; break; case "Bcc": msg.Bcc = nav.Value; break; case "Subject": //** Perform the subject token replacements msg.Subject = ReplaceTokens(n av.Value, tokens); break; case "Body": //** Perform the subject token replacements msg.Body = ReplaceTokens(n av.Value, tokens); break; default: break; }
if (!nav.MoveToNex t()) break; }
//** Send the message msg.To = recipients; SmtpMail.SmtpSe rver = smtpServer; SmtpMail.Send(m sg); }
private static string ReplaceTokens(s tring source, Hashtable tokens) { string result = source; foreach (string key in tokens.Keys) { result = result.Replace( key, tokens[key].ToString()); }
return result; } }
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tom |
last post by:
I have an ASP application which includes an asp page which
processes a user submitted file. I would like to
automate the process so the server scans the directory
every 5 minutes and processes any files in the directory.
I would like to 'reuse' the existing logic in the asp
page. How can I create a server process to do this?
The closest I can figure out is to hook the logic into a
application/session start logic in global.asa where it...
|
by: Jerry Weinstein |
last post by:
Hi,
I know about stored procedures and that they can speed up data entry via the
SQL 'insert ' statement.
However, one drawback to this method is that using the stored procedure
still requires one to manually and individually enter each and every record
to be inserted to the database before the procedure is executed.
I want to circumvent this tedium by finding a way to use maybe a VB
application that prompts a user for the data to be...
|
by: xzzy |
last post by:
I need to automate a report in a different database (and thank yous to Terry
Kreft for pointing me in the right direction).
below is the code with the one line that does not work, marked: 'Does not
Work'
It appears that the type of object returned from the "AllReports" collection
is not a report object.
=>> I need it to be an object of type report.
|
by: Howard Kaikow |
last post by:
There's a significant problem in automating Excel from VB .NET.
Reminds me of a problem I encountered almost 3 years ago that was caused by
the Norton Auntie Virus Office plug-in.
Can anybody reproduce the behavior described below?
For this example, I am using Excel 2002 and VS .NET 2002 and VB 6.
MSFT KB article 304661 gives a trivial example of early and late binding to
Excel
from VB .NET. Note that there is a variable naming...
|
by: Supa Hoopsa |
last post by:
I am in the process of rewriting an MS Access application (access front end with SQL 2k database) in VB.NET and one of the things I would like to do is link in to the compiled Access ADE so that I can use the reports that have already been created. I have somewhere in the region of 200 reports already created in MS Access and I really don't want to have to create new ones.
I have successfully linked to the Access ADP, but would really like to...
| |
by: Liam.M |
last post by:
Hey guys....
I need to find a way to loop through all of my records in the database
( so essentially query the database) based on a Date Field ("DueDate")
and if any record falls within 2 months of this date, then Run a
Command I have already written that will send an email to my specified
person.
I already have the email side of things "down pat" BUT I just need to
automate this process. Any suggestions?
|
by: danielduq |
last post by:
Hey everyone,
This is my first post here - so I'm not sure I'll phrase this question
right, but here goes:
I need to create a Visual Basic 6 program to automate a login to a web
site and then retreive data from that site. To be honest, I don't
really know where to start. I have used VB6 in the past, but not to do
anything like this. Does anyone know of any suggested web sites to read
or sample code that you could copy and paste?
|
by: attachmatey |
last post by:
Greetings:
I'm looking for some help in automating (what I thought would be) a simple procedure in Internet Explorer. I'm trying to put the following operation under a button click in an MS Access database form:
1. Navigate to URL and click button
2. Enter user name and password
3. Apply filters (enter criteria in text boxes)
4. Execute query (another button click)
5. Export results to network server
6. Data mining using Monarch...
|
by: canajien |
last post by:
How can I get a php page to automatically send all the contents in an
email when it is generated?
I managed to hack together a script that sends an email, but it will
only send the 1st record returned and I would like it to send all the
records that are on the page when it is loaded.
<?php
$con = mysql_connect("localhost","user","pass");
if (!$con)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |