Qhov no tsis yog ib lub npe tswvyim tshiab nraim, tab sis, thaum twg kuv tau mus ua, Kuv pom muaj ntau heev "vim li cas thiaj tsis no ua hauj lwm rau kuv" thiab tsis ntau teb mus. Kuv vam tias ib tug neeg pom qhov no pab tau.
Tus me ntsis raws cai yuav xa ib tug siv tau kuv tus kheej gmail tus account ua, xws li attachments:
siv System.net.mail; siv System.net; NetworkCredential loginInfo = tshiab NetworkCredential("[Kuv tus Gmail ID]", "[Kuv tus Gmail Password]"); MailMessage msg = tshiab MailMessage(); msg.Ntawm = tshiab MailAddress("[M Gmail Id]@gmail.com"); msg.To.ADD(tshiab MailAddress("paul.galvin@arcovis.com")); msg.Ntawv = "Sim infopath dev kawm"; msg.Lub cev = "<html><lub cev><muaj zog>Lus zoo heev.</muaj zog></lub cev></html>"; msg.IsBodyHtml = tseeb; foreach (hlua aFile nyob rau hauv NIPFD.GetAttachmentNamesAndLocations()) { msg.Attachments.ADD(tshiab Symptoms(aFile)); } // Ntxiv attachments. SmtpClient neeg = tshiab SmtpClient("smtp.gmail.com"); tus thov kev pab.EnableSsl = tseeb; tus thov kev pab.UseDefaultCredentials = tsis tseeb; tus thov kev pab.Peev xwm = loginInfo; tus thov kev pab.Chaw nres nkoj = 587; tus thov kev pab.EnableSsl = tseeb; tus thov kev pab.Xa(msg); |
Ob peb tseem ceeb khoom uas tub ceevxwm kuv cia thiab lwm yam tswvyim / sau ntawv:
- Rau thawj kab ntawd tus loginInfo kwv ua ib qho kev siv tus gmail ID stripped ntawm "@gmail.com”. Li ntawd, Yog hais tias kuv gmail email chaw nyob "sharepoint@gmail.com"thiab kuv lo lus qhib yog"xyzzy"ces tus kab yuav zoo li:
NetworkCredential loginInfo = tshiab NetworkCredential("sharepoint", "xyzzy");
- Kuv tus account gmail yog teem rau koj siv cov SSL thiab cov uas tsis yog ib qho teeb meem.
- Ib co tseem qhia rau dab chaw nres nkoj siv nws txoj sia?. Kuv siv chaw nres nkoj 587 thiab nws ua haujlwm fine rau kuv.
- Hauv kuv tsev neeg, Kuv kuj yuav tsum tau xa attachments. Tias kwv NIPFD muaj ib txoj kev uas yuav paub txog qhov twg kuv attachments yog. Nws rov muaj lub siab kev (e.g. "c:\tempattachment1.jpg". Thaum kuv mus, Kuv muaj ob tug attachments thiab nkawd ob leeg tau haujlwm fine.
Kuv siv siv qhov muag saib lub studio 2008 sau txoj.
</kawg>
Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin
Huv si thiab yooj yim…
Tsaug rau koom.
Lub PowerShell Team blog nyuam qhuav tau ib tug zoo li ncej uas kuv pom invaluable li ib tug neeg rau zaub mov admin. Siv qhov muag saib lub Studio no zoo kawg thiab tiamsis muaj ntau kuv tus phooj ywg tseem tsis developers thiab tsis muaj license muas. PowerShell yim ntau tshaj li qhov hais kom ua kab thiab no puas siv tau lawv. Ib tug suggestion xwb rau qhov twg admins nws txoj sia?.
Zoo,
Jeff (www.spjeff.com / ‣ spjeff)
Xa Automated emails nrog xa-MailMessage
http://blogs.msdn.com/powershell/archive/2009/10/30/sending-automated-emails-with-send-mailmessage-convertto-html-and-the-powershellpack-s-taskscheduler-module.aspx