Sending SMTP Email across domains

jethro

New member
Joined
May 26, 2004
Messages
1
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
 
Function to send mail

PlausiblyDamp said:
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.

Code:
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;
	  }
	}

Youll only need System.Web.Mail.
So have fun !
 
Back
Top