473,387 Members | 1,572 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,387 software developers and data experts.

How to ensure the mail is sent or not in C#.Net ?

Hi to Everybody,

I have use the C#.net for send the E-mail as follows

MailMessage omsg = new MailMessage();
omsg.From = new MailAddress("sathiy.03@gmail.com");
omsg.To.Add(new MailAddress(txtEmail.Text));
//omsg.Subject = txtSubject.Text;
//omsg.Body = txtContent.Text;

if (txtSubject.Text.Trim() != "")
{
omsg.Subject = txtSubject.Text.Trim();
}
else
{
omsg.Subject = "No Subject";
}
//omsg.IsBodyHtml = true;
omsg.Body = txtContent.Text.Trim();
omsg.Attachments.Add(new Attachment("d://download.txt"));
SmtpClient client = new SmtpClient("192.168.1.5", 25);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentia ls;
//client.Host = ;
try
{
client.Send(omsg);
}
catch (SmtpFailedRecipientsException ex)
{
for (int i = 0; i < ex.InnerExceptions.Length; i++)
{
Response.Write(ex.InnerExceptions[i].FailedRecipient.ToString());
}
}

If i send the mail with attach file it did not receive but it received without attachment file.

Please give me the solution to send e-mail with attached file.

Thanks
Jun 10 '10 #1
1 1663
tlhintoq
3,525 Expert 2GB
1) please wrap your code in [noparse][code] your code here [/code] tags, as you were asked to when you created the message.

2) You are correctly adding the attachment. It sounds like the attachment was stripped out by the the SMTP sender, or the receiver's email client. That happens. Sometimes the receiver has a limit on the size of the attachment. Or a limit on the total space they can use for attachments. Or virus protection. Or the company doesn't allow attachments of a certain extension.

3) Have you tried following the example on the MSDN for creating an Attachment class object out of your file? Following the directions does wonders.
[url]http://msdn.microsoft.com/en-us/library/system.net.mail.attachment.aspx[/url]
Jun 14 '10 #2

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

Similar topics

6
by: Oliver Spiesshofer | last post by:
Hi, I am trying to send emails with the php Mail function, but umlaut and other special characters are not displayed correctly. Actually they are replaced by large X's. I checked if there is an...
6
by: behindspace | last post by:
<td style=3D"border-left: solid #aaa 1px; border-right: solid black 2px; border-top: solid black 2px; border-bottom: solid black 2px;" colspan=3D"4">Data In Cell</td> *NOTE* I didn't write...
5
by: Alicia | last post by:
Hello everyone based on the data, I created a union query which produces this. SELECT ,,, 0 As ClosedCount FROM UNION SELECT ,, 0 AS OpenedCount, FROM ORDER BY , ;
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
1
by: d3vkit | last post by:
I have a website where I write articles and people can post comments to the articles. When the comment is posted, mail is supposed to be sent to users which are subscribed to the articles comments...
5
by: Josh Nikle | last post by:
i'm sending out a text-based mail from my app, and i'd like to put a table of sorts in it. i've formated my output to form rows and columns, and it looks great...in courier. can i force the mail...
1
by: ganesh22 | last post by:
Hi, Iam using below code for sending a mail, but its not storing in my sent mail option, how can i see that one in sentmail and how can i find that mail size? MailMessage msg = new...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.