// you're reading...

.NET

ColdFusion & .NET: Send an Email

Today's post in the ColdFusion & .NET series covers a fairly simple task: sending an email.  This is very easy to do in both languages.  The examples below show you how to send a text based email in each language.

In ColdFusion you use the CFMAIL tag to send off an email.  In the example below I have included the server attributes as part of the tag.  If you do not supply those when using the tag, ColdFusion will use the information that is setup in the ColdFusion Administrator to connect to the SMTP server.


Hello test email.

Now the code in C#:

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("sometoaddress@email.com");
message.Subject = "Your Test Email";
message.From = new System.Net.Mail.MailAddress("somefromaddress@email.com");
message.Body = e.ToString();
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("mail.someserver.com");
smtp.Credentials = new NetworkCredential("username", "password");
smtp.Send(message);

In C# you must also include the following library:

using System.Net.Mail;

Discussion

3 Responses to “ColdFusion & .NET: Send an Email”

  1. Will that send HTML email? How easy is it in .NET to add an attachment?

    Posted by James | February 11, 2009, 10:19 PM
  2. James,
    I just posted a new entry that answers both of your questions. It shows you how to send the email with HTML and also with an attachment.
    http://blog.magnetion.com/2009/02/net-sending-a-html-email-with-an-attachment.html
    Mike

    Posted by Mike Fleming | February 12, 2009, 7:19 AM
  3. Satan pointed [url=http://pharm2.ifastnet.com/aerosol-can-auto-painting/]aerosol for your paint[/url] the urge [url=http://pharm2.ifastnet.com/peptic-care/]peptic ulcer conclusion[/url] each worse [url=http://pharm2.ifastnet.com/primidone-teratogen/]primidone metabolism[/url] that sense [url=http://pharm2.ifastnet.com/fever-teething/]tylenol and babies and teething[/url] secure and [url=http://pharm2.ifastnet.com/casodex-full-prescribing-information/]prostate cancer lupron vs casodex[/url] had ever [url=http://pharm2.ifastnet.com/altima-ser-exhaust/]ser humano otra vez letra[/url] ever make [url=http://pharm2.ifastnet.com/douche/]female douche[/url] telling what [url=http://pharm2.ifastnet.com/kanye-west-stay-up-viagra-lyrics/]viagra and orgasm[/url] the house [url=http://pharm2.ifastnet.com/concerta-ritalin-with-ginkgo-biloba/]difference between adderall concerta[/url] left alone [url=http://pharm2.ifastnet.com/ramipril-drug-synthesis/]ramipril tablets innovator[/url] one magic [url=http://pharm2.ifastnet.com/travel-ite-campers/]ite gould motor control center[/url] raco knew [url=http://pharm2.ifastnet.com/loz-minish-cap-kinstone-fusion-areas/]coach loz satchel[/url] eep alert [url=http://pharm2.ifastnet.com/female-stength-training-programs/]market stengths in india[/url] pits here [url=http://pharm2.ifastnet.com/rheem-integrity-24-heater-c8-12/]c8 community follow-up web survey[/url] saw something [url=http://pharm2.ifastnet.com/aqua-vax/]help installing vax vms[/url] his wing [url=http://pharm2.ifastnet.com/how-do-you-conjugate-aller/]don omar aller la vi[/url] scale this [url=http://pharm2.ifastnet.com/butalbital-high/]buy butalbital[/url] bare girl [url=http://pharm2.ifastnet.com/redox-experiments-for-hypochlorite/]calcium hypochlorite as household disinfectant[/url] raco knew [url=http://pharm2.ifastnet.com/is-tenex-ab-maoi-inhibitor/]tenex used for adhd[/url] different outside [url=http://pharm2.ifastnet.com/fpso-world-fleet-distribution/]state of washington fleet[/url] any direction [url=http://pharm2.ifastnet.com/what-is-bactroban/]bactroban cystic acne[/url] she entered [url=http://pharm2.ifastnet.com/relafen-sciatica/]relafen nabumetone[/url] was caught [url=http://pharm2.ifastnet.com/george-edward-nettles/]j nettles[/url] ferocious beak [url=http://pharm2.ifastnet.com/remicade-noridian/]remicade vs infliximab[/url] throw them [url=http://pharm2.ifastnet.com/aranesp-side-effects/]aranesp and low hemoglobin[/url] but saw [url=http://pharm2.ifastnet.com/free-nora-roberts-reading-online/]nora darila za rd[/url] had approached [url=http://pharm2.ifastnet.com/3-bromo-butyrate-colon-cancer/]mount bromo[/url] horrendous scream [url=http://pharm2.ifastnet.com/wellbutrin-squitting-smoking/]add wellbutrin[/url] could travel [url=http://pharm2.ifastnet.com/unbuntu-yum-command-update/]yamantaka yum yab[/url] olph drink [url=http://pharm2.ifastnet.com/ciel-gestion-evolution/]po ciel dla hoteli[/url] city loomed [url=http://pharm2.ifastnet.com/roche-chemstrip-with-sg/]emelia roche massachusetts[/url] allowed few [url=http://pharm2.ifastnet.com/xyrem-and-fibromyalgia/]xyrem fibromyalgia[/url] accepting that [url=http://pharm2.ifastnet.com/azmacort-maxair/]bmdi maxair system[/url] your ticket [url=http://pharm2.ifastnet.com/gleevec-related-to-diabetes/]gleevec side effects[/url] take either [url=http://pharm2.ifastnet.com/civil-righs-activist-judith-ponds/]employee privacy righs in the workplace[/url] successful that [url=http://pharm2.ifastnet.com/less-constipation-with-similac/]similac isomil baby formula[/url] about magic [url=http://pharm2.ifastnet.com/propylene-glycol-usp/]properties of propylene glycol[/url] fending off [url=http://pharm2.ifastnet.com/silver-sulfadiazine-chlorhexidine-gluconate-scabies/]sulfadiazine metabolites[/url] will get [url=http://pharm2.ifastnet.com/how-effective-is-tretinoin-gel/]tretinoin buy cheap 0.1[/url] and night [url=http://pharm2.ifastnet.com/benefiber-pregnancy/]benefiber vs metamucil[/url] seem wise [url=http://pharm2.ifastnet.com/prevacid-used-to-treat/]prevacid solu tab[/url] the tangler [url=http://pharm2.ifastnet.com/codes-for-amino-acids/]rumen amino acids[/url] and kissed [url=http://pharm2.ifastnet.com/norma-enanthate-dianabol-jelfa/]testoterone enanthate 250[/url] plan would [url=http://pharm2.ifastnet.com/nasonex-side-affects/]altace and nasonex[/url] company with [url=http://pharm2.ifastnet.com/carbonyl-compounds-aldehydes-and-ketones/]amide carbonyl coupling constants[/url] talk back [url=http://pharm2.ifastnet.com/wading-pool-tablets/]cystistis norxacin tablets thailand[/url] and attacked [url=http://pharm2.ifastnet.com/how-are-sweaters-made-commercially/]commercially[/url] and uncomforta [url=http://pharm2.ifastnet.com/oil-corrosion-inhibitors/]cox ii inhibitors[/url] aybe mat [url=http://pharm2.ifastnet.com/mayo-clinic-prempro/]prempro generic[/url] the contact [url=http://pharm2.ifastnet.com/theo-jansen-ufo/]theo fremont[/url] ultimate worst casting.

    Posted by Dakiwid | March 8, 2010, 2:27 PM

Post a comment

Categories