473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

[c#-form] Emailing Hotmail (valid sender)

77
Hi, i am creating a legitimate email program which sends emails to people in the database. I can also, add a custom email recipient if the user requires it. So I try to email my hotmail account from my program. I set the SMTP server to my works local SMTP server and I use my valid work email address as the from Email Address. This works for most email addresses. However, it seems it will not send to hotmail. I get an error "5.7.1 Unable to relay for email@hotmail.co.uk". I did some research on this and there are suggestions that hotmail thinks i am a spammer and is telling me to go away.

So, my next test was I email my hotmail account from outlook. I put the recipient email address in. The From Email Address is already setup in outlook (same as I inputted into my program). This email then sends.

Does anyone know what I need to do to send to hotmail?

Maybe there’s a way to validate the email address? Some sort of authentication with the server?

Any help on this is much appreciated,
Thanks,
Piercy
Feb 25 '08 #1
7 1667
piercy
77
Bump, anyone got any ideas? Heres the code im using to send the email. Im currently catching the error and returning 5 so ican return the info to the user.

Expand|Select|Wrap|Line Numbers
  1. private short SendEmail(string FromEmail, string ContactEmail,string Subject, string Message, ArrayList Attachments)
  2.         {
  3.                         //populate message
  4.             MailMessage objMsg = new MailMessage(FromEmail, ContactEmail, Subject, Message);
  5.  
  6.             //do attachments
  7.             foreach (string path in Attachments)
  8.             {
  9.                 //Add Attachment to attachmnt Array
  10.                 Attachment data = new Attachment(path);
  11.                 objMsg.Attachments.Add(data);
  12.             }
  13.  
  14.             //Point to SMTP server d[-_-]b
  15.             SmtpClient SmtpMail = new SmtpClient(SMTPIP);
  16.  
  17.             // Start Sending Process
  18.             try
  19.             {
  20.                 SmtpMail.Send(objMsg);
  21.             }
  22.             catch(System.Exception ex)
  23.             {
  24.                 ex.ToString();
  25.                 return 5;
  26.             }
  27.             return 0;
  28.         }
  29.  
Feb 26 '08 #2
Plater
7,872 Expert 4TB
Have you tried sending your credentials to your own smtp server?
A lot of times what you can do is limited on the SMTP Server unless you authenticate with it. Do all the authentication business and see if it gives different results.
Feb 26 '08 #3
piercy
77
Have you tried sending your credentials to your own smtp server?
A lot of times what you can do is limited on the SMTP Server unless you authenticate with it. Do all the authentication business and see if it gives different results.
Expand|Select|Wrap|Line Numbers
  1. System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("Username","Password");
  2.             //Point to SMTP server d[-_-]b
  3.             SmtpClient SmtpMail = new SmtpClient(SMTPIP);
  4.  
  5.             // Start Sending Process
  6.             try
  7.             {
  8.                 SmtpMail.Credentials = SMTPUserInfo;
  9.                 SmtpMail.Send(objMsg);
  10.             }
  11.  
Thanks for your reply however it didnt change my problem. The information im giving it is correct. I just checked it by telnetting(is that a word) the server and doing AUTH LOGIN. I then passed the base64 encoding of my username and password and it said it authenticated.

Any other ideas or am i doing something wrong?

Thanks again,
Piercy :)
Feb 27 '08 #4
kenobewan
4,871 Expert 4TB
I agree with Plater your email is not sending the right credentials. Credentials are not just username and password. View the headers of both emails and you will see the difference. Hotmail is correctly trying to block programs that flood its users with spam. Unfortunately for you, your current emails fall into this category. Websites generally use methods that do not create this problem - spammer programs/code do.
Feb 27 '08 #5
piercy
77
I agree with Plater your email is not sending the right credentials. Credentials are not just username and password. View the headers of both emails and you will see the difference. Hotmail is correctly trying to block programs that flood its users with spam. Unfortunately for you, your current emails fall into this category. Websites generally use methods that do not create this problem - spammer programs/code do.
Heres the header code from my application: (ive edited it cos i dont know what information is should give out on here so email changes and a few random digits thrown in Message id)
Expand|Select|Wrap|Line Numbers
  1. x-sender: anotherEmail@bits.uk.com
  2. x-receiver: myEmail@bits.uk.com
  3. X-SCL: 7 92.13%
  4. Received: from pc_name ([100.100.100.100]) by someserver.bits.uk.com with Microsoft SMTPSVC(6.0.3790.3959);
  5. Wed, 27 Feb 2008 13:46:40 +0000
  6. mime-version: 1.0 from: anotherEmail@bits.uk.com
  7. to: myEmail@bits.uk.com
  8. date: 27 Feb 2008 13:46:40 +0000
  9. subject: Hii
  10. content-type: text/plain;
  11. charset=us-ascii
  12. content-transfer-encoding: quoted-printable
  13. Return-Path: anotherEmail@bits.uk.com
  14. Message-ID: <someserverjhhjg3FcDXAar00000a97@someserver.bits.uk.com>
  15. X-OriginalArrivalTime: 27 Feb 2008 13:46:40.0328 (UTC) FILETIME=[2E1BEC80:01C87947]
  16.  
Then heres a similar email sent from within outlook.
Expand|Select|Wrap|Line Numbers
  1. X-Message-Delivery: Vj0asszLjQuMDt1cz0wO2k9MdfderDtsPTA7YT0x
  2. X-Message-Status: n:0
  3. X-SID-PRA: My Name <myEmail@bits.uk.com>
  4. X-Message-Info: JfgfgGTYoYF78jGA4cGI+uAYMekE5VAgcFITnOMggSU/9YSFaWKr+doBv4IgPK3pMwL+Ut2S9MkmZCS9MsR5G5OM/WyIMhgPn7MESt
  5. Received: from anchor-post-32.mail.host.net ([1.1.1.1]) by bay0-mc1-f11.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2444);
  6.      Mon, 25 Feb 2008 06:50:10 -0800
  7. Received: from mailarea.bits.uk.com ([111.111.111.111] helo=someserver.bits.uk.com)
  8.     by anchor-post-32.mail.host.net with esmtp (Exim 4.67)
  9.     id 1JTeef-000Jx5-8U
  10.     for myEmail@hotmail.co.uk; Mon, 25 Feb 2008 14:50:09 +0000
  11. X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133
  12. Content-Class: urn:content-classes:message
  13. MIME-Version: 1.0
  14. Content-Type: multipart/alternative;
  15.     boundary="----_=_NextPart_001_01C877BD.FF4ECBDC"
  16. Content-Transfer-Encoding: 7bit
  17. Subject: TEST EMAIL FROM meee
  18. Date: Mon, 25 Feb 2008 14:52:09 -0000
  19. Message-ID: <69ECAE5F4AB2DE48A0DDA9C59BDFRWE62AEE41F0C6D@someserver.bits.uk.com>
  20. X-MS-Has-Attach: 
  21. Importance: normal
  22. Priority: normal
  23. X-MS-TNEF-Correlator: 
  24. Thread-Topic: TEST EMAIL FROM meee
  25. thread-index: Ach3vf++pCS4fWpMSuWTLCA1rzjpjQ==
  26. From: "My Name" <MyEmail@bits.uk.com>
  27. To: <myEmail@hotmail.co.uk>
  28. Return-Path: myEmail@bits.uk.com
  29. X-OriginalArrivalTime: 25 Feb 2008 14:50:11.0047 (UTC) FILETIME=[B8A5FF70:01C877BD]
  30.  


Thing is when i send an internal email from outlook there are no headers. so ive sent from outlook to my hotmail.. i know theres a lot different but i dont understand how i might change my code to fix this?


Thanks again,
Piercy
Feb 27 '08 #6
Plater
7,872 Expert 4TB
Did you try putting the authentication stuff into the SMTPServer object in your C# code?
Feb 27 '08 #7
piercy
77
Did you try putting the authentication stuff into the SMTPServer object in your C# code?
Yes, also, while trying to solved this. i discovered that firstly, yahoo didnt work either. Secondly, i changed my smtp server address to our ISP's server and it worked. So we have come to the conclusion its the smtp server rather than my code.

We going to get our guys to look at it...


Thanks for your help :)

Piercy
Feb 27 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Philippe Reynolds | last post by:
Hi, I'm learning python...one of my tasks is to send out emails... I can send emails to one person at a time but not as groups.... Do you think you can help. Cheers Philippe Reynolds
1
by: Bob-O | last post by:
Need your help in sending an email message with an attachment in my VB.Net program. Sending a body message is no problem. I don't know how to use the attachment property in an emai Following is...
0
by: Özden Irmak | last post by:
Hello, In my application, I've to cast DocumentDesigner class to my own derived class,MyDocumentDesigner, in order to reach the protected properties in DocumentDesigner class. But everytime I...
3
by: tafs7 | last post by:
My code below is supposed to email me when an error occurs on the application, but it's not emailing anything. Am I missing something? I know the smtp servers I've tried work. I even added a...
1
by: Franck | last post by:
Hello, are they any way fo sending an email wihtout defining the sender? thanks
5
by: Shaan | last post by:
Hi Everybody, I am incorporating emailing feature in my VB.Net application. The code is as below. When I send email to some XYZ@buffalo.edu, it sends the email successfully, but when I send it...
8
by: Pieter | last post by:
Hi, I'm having some weird problem using the BackGroundWorker in an Outlook (2003) Add-In, with VB.NET 2005: I'm using the BackGroundWorker to get the info of some mailitems, and after each item...
1
by: crescent_au | last post by:
hi all, i have this mail() function which works fine but i've tested it with hotmail where i use hotmail email address for sender and receiver also hotmail. If I type in a not existent email...
20
by: paul814 | last post by:
I've been working on this for some time now and have gotten nowhere...hoping someone here can help. I want to take and email all records in a database for the current date when this php page is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.