Help and Support

Identificativo articolo: 889879 - Ultima modifica: martedì 23 agosto 2005 - Revisione: 1.2

Esempi di codice ASP.NET che generano contenuto di posta elettronica personalizzati per sito di Commerce Server 2002 ASP.NET registrare utenti

In questa pagina

Espandi tutto | Chiudi tutto

Sommario

in questo articolo sono esempi di codice Microsoft ASP.NET in Microsoft Visual Basic .NET e in Microsoft Visual C#. Questi esempi di codice ASP.NET generano contenuto di posta elettronica personalizzati per gli utenti del sito registrato Microsoft Commerce Server 2002 ASP.NET.

INTRODUZIONE

In questo articolo sono esempi di codice ASP.NET che generano contenuto di posta elettronica personalizzati per gli utenti del sito registrato Commerce Server 2002 ASP.NET.

Il file TestEmail.aspx e il file TestEmail.aspx.vb costituiscono il codice di esempio in Visual Basic. NET. Utilizzare questo esempio di codice per siti di soluzione di Commerce Server 2002 che utilizzano Visual Basic. NET.

Il file MSIBEmail.aspx e il file MSIBEmail.aspx.cs costituiscono il codice di esempio in Visual C#. Utilizzare questo esempio di codice per siti di soluzione di Commerce Server 2002 utilizzare Visual C#.

Istruzioni su come utilizzare questi esempi di codice in siti di Commerce Server 2002 soluzione inclusi nella sezione "Ulteriori informazioni". Questi esempi di codice vengono forniti come com'è. È necessario modificare tali esempi di codice per siti di Commerce Server 2002 ASP.NET personalizzati.

Informazioni

Esempio di codice in Visual Basic .NET

Nell'esempio di codice riportato di seguito è il file TestEmail.aspx.
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="TestEmail.aspx.vb" Inherits="Microsoft.CommerceServer.Site.TestEmail"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>TestEmail</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie3-2nav3-0" name="vs_targetSchema">
	</HEAD>
	<body MS_POSITIONING="FlowLayout">
		<table style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #ffff99; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt"
			cellSpacing="0" cellPadding="0" bgColor="#ffff99" border="1">
			<tr>
				<td width="655" valign="top">
					<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'">

From: E-mail Notifier<o:p></o:p></span></p>
					<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'">Sent:
<asp:Label id="lblSentDate" runat="server">Sent Date Label</asp:Label><o:p></o:p></span></p>
					<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'">To:
<asp:Label id="lblName" runat="server">First Name Last Name</asp:Label><o:p></o:p><o:p></o:p></span></p>
					<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'">Subject: </span><b><span style="FONT-SIZE:12pt;

COLOR:blue;

FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho';

mso-bidi-font-size:10.0pt">

New product notice</span></b><span style="mso-fareast-font-family:

'MS Mincho'"><o:p></o:p>
						</span></p>
				</td>
			</tr>
		</table>
		<p class="MsoPlainText"><b><span style="FONT-SIZE:12pt;

COLOR:blue;

mso-fareast-font-family:'MS Mincho';

mso-bidi-font-size:10.0pt"><![if

!supportEmptyParas]><![endif]><o:p></o:p></span></b></p>
		<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'">Dear 
<asp:Label id="lblFName" runat="server">FirstName</asp:Label>,<o:p></o:p></span></p>
		<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'"><span style="mso-spacerun: yes"></span>
				<o:p></o:p>
			</span></p>
		<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'">

<span style="mso-spacerun: yes"></span>We have added some exciting new products to our Web 
site. 
<asp:Label id="lblSiteLink" runat="server">SiteLink</asp:Label>    

      <o:p></o:p>.<o:p></o:p></span></p>
		<p class="MsoNormal" style='mso-layout-grid-align:none'><span style='FONT-SIZE:10pt;

COLOR:navy;

FONT-FAMILY:Arial'><![if !supportEmptyParas]><![endif]><o:p></o:p></span></p>
		<p class="MsoNormal" style='mso-layout-grid-align:none'><span style='FONT-SIZE:10pt;

COLOR:navy;

FONT-FAMILY:Arial'><span style='mso-tab-count:

1'></span>
				<o:p></o:p>
			</span></p>
		<p class="MsoPlainText"><span style="mso-fareast-font-family:

'MS Mincho'">__________________________________________

<o:p></o:p></span></p>
		<p class="MsoPlainText"><i><span style="FONT-SIZE:8pt;

FONT-FAMILY:Verdana;

mso-fareast-font-family:'MS Mincho';

mso-bidi-font-size:10.0pt">TO UNSUBSCRIBE: You

have received this e-mail notifier as a result of your personal 

registration.<BR>To unsubscribe from this e-mail notifier, click

the link below. <o:p></o:p></span></i></p>
		<p class="MsoPlainText"><i><span style="FONT-SIZE:8pt;

FONT-FAMILY:Verdana;

mso-fareast-font-family:'MS Mincho';

mso-bidi-font-size:10.0pt">
					<asp:Label id="lblOptLink" runat="server">opt-out Link</asp:Label>
					<o:p></o:p>
				</span></i></p>
	</body>
</HTML>
Nell'esempio di codice riportato di seguito è il file TestEmail.aspx.vb. Il file TestEmail.aspx.vb è il file code-behind per il file TestEmail.aspx.
Imports Microsoft.CommerceServer.Runtime
Imports Microsoft.CommerceServer.Runtime.Profiles
Imports Microsoft.CommerceServer.Runtime.TicketBase


Public Class TestEmail
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents lblFName As System.Web.UI.WebControls.Label
    Protected WithEvents lblSiteLink As System.Web.UI.WebControls.Label
    Protected WithEvents lblSentDate As System.Web.UI.WebControls.Label
    Protected WithEvents lblName As System.Web.UI.WebControls.Label

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer.
        'Do not modify it by using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim FirstName As String
        Dim LastName As String
        Dim MyProfile As Profile
        Dim SentDate As String

        SentDate = Now().ToString()

        CommerceContext.Current.AuthenticationInfo.SetAuthTicket(CommerceContext.Current.UserID, False)

        MyProfile = CommerceContext.Current.UserProfile
        If MyProfile Is Nothing Then
             Response.Write("MyProfile is nothing")
        Else
        FirstName = (MyProfile.Properties("GeneralInfo.first_name").Value).ToString()
        LastName = (MyProfile.Properties("GeneralInfo.last_name").Value).ToString()

        lblSentDate.Text = SentDate
        lblName.Text = FirstName + " " + LastName
        lblFName.Text = FirstName
        'BuildURL can add parameter/value pairs to the URL depending on what you need. Please check doc for QueryStringBuilder.
        lblSiteLink.Text = "<A HREF='" + CommerceContext.Current.QueryStringBuilder.BuildUrl("default.aspx", False) + "'>Come see us today!</A>"
        End If
    End Sub

End Class

Esempio di codice in Visual C#

Nell'esempio di codice riportato di seguito è il file MSIBEmail.aspx.
<%@ Page language="c#" Codebehind="MSIBEmail.aspx.cs" AutoEventWireup="false" Inherits="Microsoft.Solutions.Applications.MSIBEmail" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>MSIBEmail</title>
		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body MS_POSITIONING="FlowLayout">
		<table style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #ffff99; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt" cellSpacing="0" cellPadding="0" bgColor="#ffff99" border="1">
			<tr>
				<td width="655" valign="top">
					<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'"> From: E-mail Notifier<o:p></o:p></span></p>
					<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'">Sent:
							<asp:Label id="lblSentDate" runat="server">Sent Date Label</asp:Label><o:p></o:p></span></p>
					<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'">To:
							<asp:Label id="lblName" runat="server">First Name Last Name</asp:Label><o:p></o:p><o:p></o:p></span></p>
					<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'">Subject: </span><b><span style="FONT-SIZE:12pt;

COLOR:blue;

FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho';

mso-bidi-font-size:10.0pt">New product notice</span></b><span style="mso-fareast-font-family:

'MS Mincho'"><o:p></o:p>
						</span>
					</p>
				</td>
			</tr>
		</table>
		<p class="MsoPlainText"><b><span style="FONT-SIZE:12pt;

COLOR:blue;

mso-fareast-font-family:'MS Mincho';

mso-bidi-font-size:10.0pt"><![if !supportEmptyParas]><![endif]><o:p></o:p></span></b></p>
		<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'">Dear
				<asp:Label id="lblFName" runat="server">FirstName</asp:Label>,<o:p></o:p></span></p>
		<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'"><span style="mso-spacerun: yes"></span>
				<o:p></o:p>
			</span>
		</p>
		<p class="MsoPlainText"><span style="FONT-FAMILY:Tahoma;

mso-fareast-font-family:'MS Mincho'"> <span style="mso-spacerun: yes"></span>We have added some 
				exciting new products to our Web site.
				<asp:Label id="lblSiteLink" runat="server">SiteLink</asp:Label>
				<o:p></o:p>.<o:p></o:p></span></p>
		<p class="MsoNormal" style='mso-layout-grid-align:none'><span style='FONT-SIZE:10pt;

COLOR:navy;

FONT-FAMILY:Arial'><![if !supportEmptyParas]><![endif]><o:p></o:p></span></p>
		<p class="MsoNormal" style='mso-layout-grid-align:none'><span style='FONT-SIZE:10pt;

COLOR:navy;

FONT-FAMILY:Arial'><span style='mso-tab-count:

1'></span>
				<o:p></o:p>
			</span>
		</p>
		<p class="MsoPlainText"><span style="mso-fareast-font-family:

'MS Mincho'">__________________________________________
				<o:p></o:p></span></p>
		<p class="MsoPlainText"><i><span style="FONT-SIZE:8pt;

FONT-FAMILY:Verdana;

mso-fareast-font-family:'MS Mincho';

mso-bidi-font-size:10.0pt">TO UNSUBSCRIBE: You have received this e-mail notifier as a result of 
					your personal registration.<BR>
					To unsubscribe from this e-mail notifier, click the link below.
					<o:p></o:p></span></i></p>
		<p class="MsoPlainText"><i><span style="FONT-SIZE:8pt;

FONT-FAMILY:Verdana;

mso-fareast-font-family:'MS Mincho';

mso-bidi-font-size:10.0pt">
					<asp:Label id="lblOptLink" runat="server">opt-out Link</asp:Label>
					<o:p></o:p>
				</span></i>
		</p>
	</body>
</HTML>
Nell'esempio di codice riportato di seguito è il file MSIBEmail.aspx.cs. Il file MSIBEmail.aspx.cs è il file code-behind per il file MSIBEmail.aspx.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.CommerceServer.Runtime;
using Microsoft.CommerceServer.Runtime.Profiles;

namespace Microsoft.Solutions.Applications
{
	/// <summary>
	/// Summary description for MSIBEmail.
	/// </summary>
	public class MSIBEmail : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label lblSentDate;
		protected System.Web.UI.WebControls.Label lblName;
		protected System.Web.UI.WebControls.Label lblFName;
		protected System.Web.UI.WebControls.Label lblSiteLink;
		protected System.Web.UI.WebControls.Label lblOptLink;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			string FirstName;
			string LastName;
			Profile MyProfile;
			string SentDate;

			SentDate = DateTime.Now.ToString();
			CommerceContext.Current.AuthenticationInfo.SetAuthTicket(CommerceContext.Current.UserID, false);

			MyProfile = CommerceContext.Current.UserProfile;

			if (MyProfile!=null)
			{
				FirstName = (MyProfile.Properties["GeneralInfo.first_name"].Value).ToString();
                LastName = (MyProfile.Properties["GeneralInfo.last_name"].Value).ToString();

                lblSentDate.Text = SentDate;
                lblName.Text = FirstName + " " + LastName;
                lblFName.Text = FirstName;
                //BuildURL can add parameter/value pairs to the URL depending on what you need. Please check doc for QueryStringBuilder.
                lblSiteLink.Text = "<A HREF='" + CommerceContext.Current.QueryStringBuilder.BuildUrl("default.aspx", false) + "'>Come see us today!</A>";
                //Opt-out.asp is another page that you must work on if you need this feature.
                lblOptLink.Text = "<A HREF='" + CommerceContext.Current.QueryStringBuilder.BuildUrl("opt-out.aspx", false) + "'>Click here to opt-out of future mailings.</A>";
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support. Do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

Come utilizzare questi esempi di codice

È possibile utilizzare questi esempi di codice nei siti di Commerce Server 2002 soluzione per generare il contenuto di posta elettronica personalizzati per gli utenti del sito registrato Commerce Server 2002 ASP.NET. A tale scopo, attenersi alla seguente procedura:
  1. In un sito di soluzione di Commerce Server 2002 che utilizza Visual Basic. NET, creare la pagina di contenuto posta elettronica utilizzando il file TestEmail.aspx e il file TestEmail.aspx.vb. In un sito di soluzione di Commerce Server 2002 che utilizza C#, creare la pagina di contenuto posta elettronica utilizzando il file MSIBEmail.aspx e il file MSIBEmail.aspx.cs.
  2. Visitare il sito, accedere con un account registrato e quindi visitare la pagina contenuto di posta elettronica per vedere se la pagina di contenuto della posta.
  3. Creare un elenco di Commerce Server 2002 Business scrivania. A tale scopo, attenersi alla seguente procedura:
    1. Nella finestra di campagne , fare clic su Gestore elenchi .
    2. In Gestore elenchi , fare clic sul pulsante Importa .
    3. Nella finestra di dialogo Importa un elenco fare clic su da database di SQL in origine elenco .
    4. Nella finestra di dialogo Importa un elenco di digitare un nome per l'elenco. Ad esempio, digitare MyDirectMailList .
    5. In Commerce Server Manager, espandere Commerce Server Manager , espandere le risorse globali , espandere i profili e quindi copiare la stringa di connessione dei profili. Nella finestra di dialogo Importa un elenco di incollare la stringa di connessione nella stringa di connessione .
    6. Nella casella query SQL , aggiungere la seguente query di esempio.
      select u_email_address As rcp_email, g_user_id as rcp_guid from UserObject where i_user_type=1
    Nota Gli utenti registrati deve essere già presente prima si crea l'elenco.
  4. Creare una campagna di posta diretta.

    Nota Per ulteriori informazioni creare una campagna di mailing diretto, vedere la sezione "impostazione fino a posta diretta campagna" della documentazione di Commerce Server 2002.
  5. Nella definizione di posta diretta, nella casella Percorso o URL contenente messaggio , digitare l'URL del file MailContent.aspx. Ad esempio, digitare il seguente URL:
    http:// myCommerceServer myCommerceServer//MailContent.aspx myCommerceSite
  6. Inviare messaggi di posta elettronica di prova all'elenco che viene creata nel passaggio 3.

Le informazioni in questo articolo si applicano a:
  • Microsoft Commerce Server 2002 Standard Edition
  • Microsoft Commerce Server 2002 Service Pack 3
  • Microsoft Commerce Server 2002 Service Pack 1
Chiavi: 
kbmt kbinfo KB889879 KbMtit
Traduzione automatica articoliTraduzione automatica articoli
Il presente articolo è stato tradotto tramite il software di traduzione automatica di Microsoft e non da una persona. Microsoft offre sia articoli tradotti da persone fisiche sia articoli tradotti automaticamente da un software, in modo da rendere disponibili tutti gli articoli presenti nella nostra Knowledge Base nella lingua madre dell?utente. Tuttavia, un articolo tradotto in modo automatico non è sempre perfetto. Potrebbe contenere errori di sintassi, di grammatica o di utilizzo dei vocaboli, più o meno allo stesso modo di come una persona straniera potrebbe commettere degli errori parlando una lingua che non è la sua. Microsoft non è responsabile di alcuna imprecisione, errore o danno cagionato da qualsiasi traduzione non corretta dei contenuti o dell?utilizzo degli stessi fatto dai propri clienti. Microsoft, inoltre, aggiorna frequentemente il software di traduzione automatica. Nel caso in cui si riscontrino degli errori e si desideri inviare dei suggerimenti, è possibile completare il questionario riportato alla fine del presente articolo.
Clicca qui per visualizzare la versione originale in inglese dell?articolo: 889879  (http://support.microsoft.com/kb/889879/en-us/ )
LE INFORMAZIONI CONTENUTE NELLA MICROSOFT KNOWLEDGE BASE SONO FORNITE SENZA GARANZIA DI ALCUN TIPO, IMPLICITA OD ESPLICITA, COMPRESA QUELLA RIGUARDO ALLA COMMERCIALIZZAZIONE E/O COMPATIBILITA' IN IMPIEGHI PARTICOLARI. L'UTENTE SI ASSUME L'INTERA RESPONSABILITA' PER L'UTILIZZO DI QUESTE INFORMAZIONI. IN NESSUN CASO MICROSOFT CORPORATION E I SUOI FORNITORI SI RENDONO RESPONSABILI PER DANNI DIRETTI, INDIRETTI O ACCIDENTALI CHE POSSANO PROVOCARE PERDITA DI DENARO O DI DATI, ANCHE SE MICROSOFT O I SUOI FORNITORI FOSSERO STATI AVVISATI. IL DOCUMENTO PUO' ESSERE COPIATO E DISTRIBUITO ALLE SEGUENTI CONDIZIONI: 1) IL TESTO DEVE ESSERE COPIATO INTEGRALMENTE E TUTTE LE PAGINE DEVONO ESSERE INCLUSE. 2) I PROGRAMMI SE PRESENTI, DEVONO ESSERE COPIATI SENZA MODIFICHE, 3) IL DOCUMENTO DEVE ESSERE DISTRIBUITO INTERAMENTE IN OGNI SUA PARTE. 4) IL DOCUMENTO NON PUO' ESSERE DISTRIBUITO A SCOPO DI LUCRO.

Traduzione articoli

 

Related Support Centers