Cannot Send SMTP Email


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
On our Exchange server, one of the anti-spam policies was being run in the wrong order. I moved the Custom Allow by IP Address up before the Anti-Spoofing policy and now I can send intra-domain emails via code.



I am glad I finally got this solved. BigGrin



Time for a vacation. w00t
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
That doesn't make any sense! This could be coming from your mail server more than from the SMTP client. I will have to test this and see if I get the same results...that is definitely strange! Glad you got it going! Smile
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Sorry...apparently highlighting does not work within a code snippet. The key change was the following line:



mMail.From = new MailAddress("aspire@spiratex.net");

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Here's the thing guys (btw, thanks to everyone for the help...much appreciated!), the From address cannot be in the same domain.



Yup, I agree it is quite odd. Here is my adjusted code that actually works!





MailMessage mMail = new MailMessage();

mMail.IsBodyHtml = true;

mMail.Body = String.Format("Sales order ID {0} has been recently edited by {1}. The new order total {2:c} has increased which exceeds the previously approved amount of {3:c}.", mSalesOrder.orderid, AspireGlobals.CurrentUser.FullName, mSalesOrder.OrderTotal, _salesordertotal);

[highlight=#ffff11]mMail.From = new MailAddress("aspire@spiratex.net");[/highlight]

mMail.Subject = "Sales Order Exceeds Approved Total!";

mMail.To.Add("userA@spiratex.com");

mMail.CC.Add("userB@spiratex.com");

SmtpClient mSmtpClient = new SmtpClient("SPFS01");

try

{

mSmtpClient.Send(mMail);

}

catch (Exception ex)

{

MessageForm.ShowMessage("Aspire Information", String.Format("{0} :: {1} ({2})", ex.Message, ex.InnerException, ex.StackTrace), "Send Email", MicroFour.StrataFrame.Messaging.MessageFunction.OK, MicroFour.StrataFrame.Messaging.MessagingIcon.Information, MicroFour.StrataFrame.Messaging.MessagingSounds.Notify);

}





This is working so I can pragmatically move on. Does anyone know the reason for this behavior?



Thanks, again!

Bill
Keith Chisarik
Keith Chisarik
StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
Bill, I PM'd you some code to test using my public SMTP server, I know the code works, if you cant send with that... it must be ISP, firewall, etc

Keith Chisarik
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Be aware that many antivirus program will block port 25 for SMTP and also may ISP may monitor the traffic used by the smtp and may be blocking out your IP or your SMTP server.

Edhy Rijo

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Thanks! I did try the NetworkCredential's route as you guys outlined. Still no email gets sent. Still stumped.
Keith Chisarik
Keith Chisarik
StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
I know this works. MyEmail is just a structure that holds the email content and authentication info.

Public Sub SendEmail(ByVal messageInfo As MyEmail)

Dim mail_Email As New MailMessage()

Dim smtp As New SmtpClient(messageInfo._smtpServer)

mail_Email.To.Add(messageInfo._ToAddress)

mail_Email.From = New MailAddress(messageInfo._FromAddress, messageInfo._FromText)

mail_Email.Subject = messageInfo._Subject

mail_Email.IsBodyHtml = True

mail_Email.Body = Err.ToString

smtp.Credentials = New Net.NetworkCredential(messageInfo._smtpUser, messageInfo._smtpPassword)

smtp.Send(mail_Email)

mail_Email.Dispose()

End Sub



Keith Chisarik
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yeah, if you do not support relay (as you most likely do not) then you need to supply the credentials. For example:



SmtpClient _SMTP = new SmtpClient("MyMailServer", 25);

NetworkCredential _LoginCredentials = new NetworkCredential("UserName", "Password", "Domain");



_SMTP.Credentials = _LoginCredentials;




You may add this and see if you get anywhere. I will say, however, that you will generally get an error if it cannot authenticate. But this might at least prompt some ideas!
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I am stumped...here is my code:





MailMessage mMail = new System.Net.Mail.MailMessage();

mMail.Body = String.Format("Sales order ID {0} has been recently edited by {1}. The new order total {2:c} has increased which exceeds the previously approved amount of {3:c}.", mSalesOrder.orderid, AspireGlobals.CurrentUser.FullName, mSalesOrder.OrderTotal, _salesordertotal);

mMail.From = new MailAddress(AspireGlobals.CurrentUser.EmailAddress);

mMail.Subject = "Sales Order Exceeds Approved Total!";

mMail.To.Add(new MailAddress("bcunnien@spiratex.com"));

SmtpClient mSmtpClient = new SmtpClient("192.168.2.247");

mSmtpClient.UseDefaultCredentials = true;

try

{

mSmtpClient.Send(mMail);

}

catch (Exception ex)

{

MessageForm.ShowMessage("Aspire Information", String.Format("{0} :: {1} ({2})", ex.Message, ex.InnerException, ex.StackTrace), "Send Email", MicroFour.StrataFrame.Messaging.MessageFunction.OK, MicroFour.StrataFrame.Messaging.MessagingIcon.Information, MicroFour.StrataFrame.Messaging.MessagingSounds.Notify);

}





I get no error. No email is sent. The IP address is our Exchange server. Is there some credential's trick that I need to get SMTP traffic to flow through our Exchange server? I have tried other servers that have SMTP running, but none of them are sending an email, either. I can watch a connection being established in the Client Connections of the SMTP server via IIS...the connection persists until I actually close my application or it times out.



Anyone have any ideas about this one?



Thanks!!

Bill
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search