Hii si hasa mada mpya, lakini wakati mimi zinahitajika kufanya hivyo, I found a lot of “why won’t this work for me” and not too many direct answers. I hope someone finds this useful.
kidogo yafuatayo ya maadili ya kutuma email kwa kutumia gmail yangu mwenyewe akaunti ya kufanya hivyo, ikiwa ni pamoja na attachments:
kutumia System.Net.Mail; kutumia System.Net; NetworkCredential loginInfo = mpya NetworkCredential("[ID yangu ya Gmail]", "[Siri yangu ya Gmail]"); MailMessage msg = mpya MailMessage(); msg.From = mpya MailAddress("[M Gmail Id]@ Gmail.com"); msg.To.Add(mpya MailAddress("paul.galvin@arcovis.com")); msg.Subject = "Test infopath dev subject"; msg.Body = "<html><mwili><nguvu>ujumbe mzito.</nguvu></mwili></html>"; msg.IsBodyHtml = kweli; foreach (string aFile katika NIPFD.GetAttachmentNamesAndLocations()) { msg.Attachments.Add(mpya Attachment(aFile)); } // Kuongeza attachments. SmtpClient mteja = mpya SmtpClient("smtp.gmail.com"); client.EnableSsl = kweli; client.UseDefaultCredentials = uongo; client.Credentials = loginInfo; client.Port = 587; client.EnableSsl = kweli; client.Send(msg); |
chache muhimu bits kwamba umepungua yangu chini na uchunguzi mwingine / maelezo:
- mstari wa kwanza kuwa inajenga kitu loginInfo mahitaji ya kutumia ID gmail kuvuliwa "@ Gmail.com". Hivyo, kama yangu ya barua pepe ni gmail "Sharepoint@gmail.com"Na password yangu ni" xyzzy "basi line bila kuangalia kama:
NetworkCredential loginInfo = mpya NetworkCredential("sharepoint", "xyzzy");
- Akaunti yangu ya gmail ni kuanzisha kutumia SSL na kwamba halikuwa tatizo.
- There is some conflicting information out there on what port to use. I used port 587 na ni kazi nzuri kwa ajili yangu.
- Katika kesi yangu, I also needed to send attachments. That NIPFD object has a method that knows where my attachments are. It’s returning a fully path (e.g. "C:\temp\attachment1.jpg”. In my test, Mimi nilikuwa na attachments mbili na wao wote kazi nzuri.
Nilikuwa studio ya Visual 2008 kuandika kanuni hii.
</mwisho>
Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin
Safi na rahisi…
Shukrani kwa kushirikiana.
Timu PowerShell blog hivi karibuni alikuwa na wadhifa sawa kwamba mimi kupatikana mchango mkubwa sana kama admin server. Visual Studio ni kubwa lakini wengi wa rika yangu si watengenezaji na hawana leseni kununuliwa. PowerShell anahisi zaidi kama mstari amri na ni zaidi kupatikana kwao. Tu pendekezo kwa yoyote admins huko nje.
Bora,
Jeff (www.spjeff.com / @ Spjeff)
Kutuma barua pepe kujiendesha na Send-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