i am new to vb.net. i would like to create a class for sending emial . i tried the script online but i failed to send. So i got this code below from the hosting server. May i know how do i simplify the below script to just receive FromEmail, Subject, Message ? why it needs the mailerpath?mailerport? and errText? isn't we can check those error in the form instead of class ? Please kindly advice. thanks <pre> ' **** MailerPath = Your SMTP path (for eg: mail.[domain].com) *** function CDOSYS_Mailer(Message, FromEmail, ToEmail, FromName, ToName, Subject, MailerPath, MailerPort, errText, searchURL) on error resume next dim Mailer set Mailer = server.createobject("CDO.Message") if err.number <> 0 then errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description) CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0 exit function end if Mailer.From = FromName & " <" & FromEmail & ">" Mailer.To = ToName & " <" & ToEmail & ">" Mailer.TextBody = Message Mailer.Subject = Subject with Mailer.Configuration .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailerPath .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailerPort .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1 .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")="test@yourdomain.com" .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")="youremailpassword" .Fields.Update end with Mailer.Send if err.number <> 0 then errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description) CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0 exit function end if set Mailer = Nothing CDOSYS_Mailer = true end function</pre>
angels777
Posts
-
send email -
send emaili am new to vb.net. i would like to create a class for sending emial . i tried the script online but i failed to send. So i got this code below from the hosting server. May i know how do i simplify the below script to just receive FromEmail, Subject, Message ? why it needs the mailerpath?mailerport? and errText? isn't we can check those error in the form instead of class ? Please kindly advice. thanks
' **** MailerPath = Your SMTP path (for eg: mail.[domain].com) ***
function CDOSYS_Mailer(Message, FromEmail, ToEmail, FromName, ToName, Subject, MailerPath, MailerPort, errText, searchURL)
on error resume nextdim Mailer
set Mailer = server.createobject("CDO.Message")
if err.number <> 0 then
errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description)
CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0
exit function
end ifMailer.From = FromName & " <" & FromEmail & ">"
Mailer.To = ToName & " <" & ToEmail & ">"
Mailer.TextBody = Message
Mailer.Subject = Subject
with Mailer.Configuration
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailerPath
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailerPort
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")="test@yourdomain.com"
.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")="youremailpassword"
.Fields.Update
end with
Mailer.Send
if err.number <> 0 then
errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description)
CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0
exit function
end if
set Mailer = Nothing
CDOSYS_Mailer = true
end function -
regexpublic bool IsInteger(string sender) { Regex regex = new Regex("[^0-9]"); return !regex.IsMatch(sender); } hi i get confused with the code above... why when i put e.g. 333 as the sender.. regex.IsMatch(sender); this is returning false ?? and i must put a ! there ?? my logic is .. when regex[^0-9] = integer then it must return true... pls advice
-
how to get the correct codethanks for the wonderful reply... BUT .. i just cant get the $#&(#$ manager Error 3 The name 'ConfigurationManager' does not exist in the current context i had put the below script in the constructor as what u told..also added the using System.Configuration;
this.connectionString = ConfigurationManager.AppSettings["connectionString"];
but just no manager come out..
-
how to get the correct codei declare under this.. as global.. i do not want each function declare that.. namespace ttt { public class Dataaccess { private string sqlString = System.Configuration.ConfigurationSettings.AppSettings["connectionString"].ToString(); private SqlConnection cn;
-
how to get the correct codeyes.. i had added.. the using System.Configuration but still don have the manager thing.
-
how to get the correct codeafter included i cant find the COnfigurationManager also ... system.configuration. only have .ConfigurationSettings and .ConfigurationException
-
how to get the correct codemay i know how to clear this error ? i tried use this System.Configuration.ConfigurationManager.AppSettings' but i canot find the .configurationManager.. private string sqlString = System.Configuration.ConfigurationSettings.AppSettings["connectionString"].ToString(); Warning 2 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'
-
doing validation in other file.csThank for the reply.. can u pls show some example to get all verification done is the class ? or at least guide me on declaring or passing the e thanks
-
doing validation in other file.cshi i would like to seperate my design page from validation. so i put the validation code in e.g validate.cs design form
private void textboxInteger_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
validate.txtIntValidate(txtPhone.text)
}in my validate class
class Validate
{
public bool txtIntValidate(string txt)
{
if (!Char.IsDigit(e.KeyChar) && e.KeyChar != (char)8)
{
e.Handled = true; // input is not passed on to the control(TextBox)
}
}
}BUT in the validate.cs class .. how do i declare the e.. Error 3 The name 'e' does not exist in the current context
-
listview.may i know how do i get the ID from the datagridview ?
-
listview.hi.. sorry.. i think i would like to use up the DataGridView called dvCustomer under private void dvCustomer_SelectionChanged(object sender, EventArgs e) { } when i click on the datagridview row... i would like to get the user ID from database. so that i can do the update as below ..
private void cust_update_Click(object sender, EventArgs e)
{
bool success;
success = dataAccess.AddCustomer(Datagridview ID, cust_name.Text, cust_add.Text, cust_account.Text, cust_phone.Text...);
if (success)
{
MessageBox.Show("Data updated!");
}
else
{
MessageBox.Show("Update FAIL!!!");
}
}in my dataAccess class
public bool AddCustomer(string function, string custName, string custAdd, string custAcc, string custPhone.....)
{
bool success = false;
string query = string.Empty;
try
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@companyName", custName));
cmd.Parameters.Add(new SqlParameter("@customerAdd", custAdd));
cmd.Parameters.Add(new SqlParameter("@attName", custAdd));
cmd.Parameters.Add(new SqlParameter("@customerAcc", custAcc));
cmd.Parameters.Add(new SqlParameter("@customerPhone", custPhone));query += "UPDATE CUSTOMER set company_name= @companyName, company_add= @customerAdd, att_name= @attName, account_num= @customerAcc, phone= @customerPhone...........";
query += " where cust_id = ?????????? ";cmd.CommandText = query; if (cn.State == ConnectionState.Closed) cn.Open(); cmd.Connection = cn; if (cmd.ExecuteNonQuery() > 0) { success = true; return success; }
-
listview.hi.. why when i drag out a listview in vs 2005. i cant get teh function of listview.selectedindex ? only selecteditem .. i want to get the id of the data selected ..
-
listview problemhi.. i have a question related to the listview.. i did the below things.. but how do i assign the value to the listview /?
void call_listview()
{
cmd.Connection = con;
cmd.CommandText = "select * from contact";
da.SelectCommand = cmd;DataTable store = new DataTable(); try { ds.Clear(); con.Open(); da.Fill(ds); store = ds.Tables\[0\]; int count\_friend = store.Rows.Count; contact\_total\_friends.Content = count\_friend; contact\_listview.DataContext = ds.Tables\[0\].DefaultView; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } }
-
Software integration has always been a big problemcan .NET run in UNIX ?
-
Software integration has always been a big problemIn a large organization, if you have UNIX applications, mainframe applications, Windows applications, etc. How do you get these to talk to each other? may i know how .NET solve this problem ? also, during deployment,we have to worry about which version of IE is installed, which version of MDAC is installed, etc. we may have to test our install on Windows 95, 98, ME, NT, 2000, and XP, with different service packs, to insure that the install and uninstall work correctly. may i know how .NET solve this ?
-
overridingclass A { public virtual void F() {} } class B: A { new private void F() {} // Hides A.F within B } class C: B { public override void F() {} // Ok, overrides A.F } may i knwo whta is Hides A.F within B and overrides A.F ?? thanks
-
what is this meanHi may i know what is the 0000000 mean? CREATE PROCEDURE [users_retrieve] @UserId bigint = 00000000,
-
get curson position in richtextobxhi i tried insert the emoticon in the richtectbox where it follows my cursor position.. but it always go to behind text
Image imgCtrl = new Image(); BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.StreamSource = Application.GetResourceStream(new Uri("pic.jpg", UriKind.RelativeOrAbsolute)).Stream; bmp.EndInit(); imgCtrl.Source = bmp; InlineUIContainer iu = new InlineUIContainer(imgCtrl); TextPointer pos = richBox.CaretPosition; pos.Paragraph.Inlines.Add(iu);
-
maintain back the combobox itemhow do i make the comboxitem isselected when i retrived back the data from database? i tried as below if reminder is 1 day , the comboxboxitem (reminder1) will be selected.. is this correct? if (row["reminder"].ToString().Trim() == "1") { reminder_1.IsSelected = true ; }