Dan mhux eżattament suġġett ġdid, iżda meta I meħtieġa biex jagħmlu dan, I found a lot of “why won’t this work for me” and not too many direct answers. I hope someone finds this useful.
Il-daqsxejn ta 'kodiċi li ġej se tibgħat email bl-użu kont gmail tiegħi stess biex jagħmlu dan, inkluż attachments:
użu System.Net.Mail; użu System.Net; NetworkCredential loginInfo = ġdid NetworkCredential("[ID Gmail tiegħi]", "[Password Gmail tiegħi]"); MailMessage MSG = ġdid MailMessage(); msg.From = ġdid MailAddress("[M Gmail Id]@ Gmail.com"); msg.To.Add(ġdid MailAddress("paul.galvin@arcovis.com")); msg.Subject = "Test infopath dev subject"; msg.Body = "<html><korp><qawwija>A messaġġ qawwi.</qawwija></korp></html>"; msg.IsBodyHtml = vera; foreach (string aFile fil NIPFD.GetAttachmentNamesAndLocations()) { msg.Attachments.Add(ġdid Attachment(aFile)); } // Żieda attachments. SmtpClient klijent = ġdid SmtpClient("smtp.gmail.com"); client.EnableSsl = vera; client.UseDefaultCredentials = falza; client.Credentials = loginInfo; client.Port = 587; client.EnableSsl = vera; client.Send(MSG); |
A bits ewlenin ftit li naqas me isfel u osservazzjonijiet oħra / noti:
- L-ewwel linja li toħloq l-oġġett loginInfo jeħtieġ li tuża l-ID gmail imqaxxar mill- "@ Gmail.com". Allura, jekk l-indirizz email tiegħi huwa gmail "Sharepoint@gmail.com"U password tiegħi huwa" xyzzy "imbagħad il-linja look like:
NetworkCredential loginInfo = ġdid NetworkCredential("sharepoint", "xyzzy");
- Kont gmail tiegħi huwa stabbilit għall-użu SSL u li ma kienet problema.
- There is some conflicting information out there on what port to use. I used port 587 u maħduma multa għalija.
- Fil-każ tiegħi, 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, I kellu żewġ żjidiet u tnejn li huma maħduma multa.
I użati studio viżwali 2008 li tikteb dan il-kodiċi.
</aħħar>
Follow lili Twitter fi http://www.twitter.com/pagalvin
Nadif u sempliċi…
Grazzi għall-qsim.
Il-blog Tim PowerShell reċentement kellhom post simili li sibt imprezzabbli bħala admin server. Visual Studio huwa kbir iżda ħafna ta 'sħabhom tiegħi mhumiex iżviluppaturi u ma jkollhom liċenzja mixtrija. PowerShell jħoss aktar bħal kmand tal-linja u huwa aktar aċċessibbli għalihom. Just suġġeriment għal kwalunkwe admins hemmhekk.
Best,
Jeff (www.spjeff.com / @ Spjeff)
Mittenti emails Automated mal Ibgħat-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