![]() |
Mails versenden mit .net
@all
Da immer wieder einmal nach einer Lösung zum versenden von Mails gesucht wird, und zwar ohne Outlook einzubinden, hier die offizielle Microsoft Lösung. (Codiert in C#) Funktioniert mit Delphi 2005 einwandfrei. Grüße, Highway
Delphi-Quellcode:
private void btnSendMail_Click(object sender, System.EventArgs e)
{ string smtpServer = "smtp.1und1.de"; string userName = "***********"; // Hier gehört das Konto hin! string password = "***********"; // Hier das Passwort! int cdoBasic = 1; int cdoSendUsingPort = 2; MailMessage msg = new MailMessage(); if (userName.Length > 0) { msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer); msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25) ; msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort) ; msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic); msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName); msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password); } msg.To = "xyz@gmx.de"; msg.From = "mymail@gmx.de"; msg.Subject = "Subject"; msg.Body = "Message"; SmtpMail.SmtpServer = smtpServer; SmtpMail.Send(msg); } |
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:14 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz