jethro Posted May 26, 2004 Posted May 26, 2004 When sending email I get a Delivery Status Notification (Failure) for any recipients outside my domain. My code is as follows: Const cdoSendUsingMethod As String = "http://scemas.microsoft.com/cdo/configuration/sendusing" Const cdoSMTPServer As String = "http://schemas.microsoft.com/cdo/configuration/smtpserver" Const cdoSMTPServerPort As String = "http://schemas.microsoft.com/cdo/configuration/smtpserverport" EmailList = db.RetrieveRow(sql) EmailSendTo = EmailList(0) 'EmailSendTo = "mylist@mylist.com" EmailSubject = ReportName & " Report for " & Date.Now.ToShortDateString EmailBody = EmailList(1) & " " & Date.Now.ToShortDateString & ". Please contact me if you have questions or concerns." Try objMessage = CreateObject("CDO.Message") With objMessage.Configuration .Fields(cdoSendUsingMethod) = cdoSendUsingPort .Fields(cdoSMTPServer) = "smtp.comcast.net" .Fields(cdoSMTPServerPort) = 25 .Fields.Update() End With With objMessage .MimeFormatted = True '. .From = gFrom .To = EmailSendTo .Subject = EmailSubject .TextBody = EmailBody .AddAttachment(ReportPath) .Send() End With Catch ex As Exception End Try objMessage = Nothing Quote
Administrators PlausiblyDamp Posted May 26, 2004 Administrators Posted May 26, 2004 IIRC you will need to configure the SMTP service (via Internet Information Services Manager) to relay mail to other domains. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Arch4ngel Posted May 26, 2004 Posted May 26, 2004 Function to send mail IIRC you will need to configure the SMTP service (via Internet Information Services Manager) to relay mail to other domains. This is a function that I used to send mail from an account that require auth. public bool SendMail( string CONTENT) { try { string bcc = ""; string to = "yourmail@mail.com"; string from = "yourmail@mail.com"; string subj = "SOME SUBJECT"; string username = "USER"; string password = "PASSWORD"; MailMessage msg = new MailMessage(); msg.Bcc = bcc; msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "smtp.yourserver.com"; msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = 25; msg.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = username; msg.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = password; msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = "1"; msg.To = to; msg.From = from; msg.Subject = subj; msg.Body = CONTENT; // Here you can set if you want HTML format or plain text msg.BodyFormat = MailFormat.Html; SmtpMail.SmtpServer = m_Serveur; SmtpMail.Send(msg); msg = null; return true; } catch( Exception e) { Console.WriteLine( e.Message); return false; } } You'll only need System.Web.Mail. So have fun ! Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.