|
I am Sending a Mail with attachemts for this I have Made A WCF Which works fine when I give the Network path of the file. but I need to host It And when I try to give a URL path It Says. URI format not supported please Help My Code in WCF
public List<string> funSendMail(Mailcls m)<br />
{<br />
List<string> result = new List<string>();<br />
try<br />
{<br />
<br />
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(m.Sender, m.Receiver);<br />
<br />
if (m.Cc != null && m.Cc != string.Empty)<br />
{<br />
mailMessage.CC.Add(m.Cc);<br />
}<br />
<br />
if (m.Bcc != null && m.Bcc != string.Empty)<br />
{<br />
mailMessage.Bcc.Add(m.Bcc);<br />
}<br />
mailMessage.Subject = m.Subject;<br />
mailMessage.Body = m.Body;<br />
<br />
<br />
<br />
mailMessage.IsBodyHtml = true;<br />
<br />
<br />
<br />
<br />
if ((m.AttachfilesPath != null) && (m.AttachfilesPath.Count > 0))<br />
{<br />
foreach (string s in m.AttachfilesPath)<br />
{<br />
result.Add("Attaching File : " + s);<br />
<br />
System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(s); <br />
<br />
mailMessage.Attachments.Add(attach);<br />
}<br />
<br />
}<br />
<br />
<br />
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();<br />
smtpClient.Host = m.Host;<br />
smtpClient.Port = m.Port;<br />
smtpClient.UseDefaultCredentials = true;<br />
smtpClient.Credentials = new System.Net.NetworkCredential(m.UserName, m.Password);<br />
smtpClient.EnableSsl = m.SSL;<br />
smtpClient.Send(mailMessage);<br />
<br />
try<br />
{<br />
<br />
<br />
foreach (string s in m.AttachfilesPath)<br />
{<br />
File.Delete(s);<br />
}<br />
}<br />
catch { }<br />
result.Add("1");<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
result.Add("-2 " + ex.Message);<br />
}<br />
return result;<br />
<br />
}
and In Calling Appication (Which is a Silverlight Application)
ObservableCollection<string> cv = new ObservableCollection<String>();<br />
cv.Add(@"www.msdotnetmentor.com/wp-content/uploads/2009/08/5.JPG");
Mail.Bcc = txtBCC.Text;<br />
Mail.Body = txtMailBody.Text;<br />
Mail.Cc = txtCC.Text;<br />
Mail.AttachfilesPath = cv;<br />
Mail.Host = EditDeleteEmailConfig.SMTPHost;<br />
Mail.Password = EditDeleteEmailConfig.SMTPPassword;<br />
Mail.Port = EditDeleteEmailConfig.SMTPPort;<br />
Mail.Receiver = txtTo.Text;<br />
Mail.Sender = txtFrom.Text;<br />
Mail.SSL = EditDeleteEmailConfig.SMTPSSL;<br />
Mail.Subject = txtSubject.Text;<br />
Mail.UserName = EditDeleteEmailConfig.SMTPUserName;<br />
SuccessMessage = "Mail Sent Successfully";<br />
ErrorMessage = "Error In Sending Mail" + Environment.NewLine + "Try Sending Later";<br />
if (EmailSettings)<br />
{<br />
SendClient.funSendMailAsync(Mail);<br />
SendClient.funSendMailCompleted += new EventHandler<funSendMailCompletedEventArgs>(SendClient_funSendMailCompleted);<br />
}<br />
else<br />
{<br />
EditDeleteEmailConfig = new EmailConfig();<br />
IsSendMail = true;<br />
EmailSettingsClient.GetEamilConfigByClientIdAsync(userID);<br />
}
modified on Friday, September 11, 2009 8:56 AM
|
|
|
|
|
Might adding http:// cause it to know it's a web address ? ( this has nothing to do wtih ASP.NET, btw )
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I tried It That way too. If I add Http:// The it says URI format not supported and if i remove that then it says path not found as it adds the extra path thill bin dir to the actula path
|
|
|
|
|
Looking at your code a bit more, I am not surprised. You're asking the mail code to do a HTTP transfer on your behalf, but I doubt that is supported. So, the error is correct. Why do you want to mail an image from a hard coded URL ? Why not make that image a local file ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
See That Image is a local file but Silverlight or WCf service can't access the local path of the client system. so i uploaded that on my server using a WCF for upload files. now attaching it to the mail. as silverlight has its contrains...
|
|
|
|
|
Well, I would imagine if there's a solution, it involves doing a HTTP request to get the file bytes, I know silverlight gives you a sandbox you could use to save the file, and then send it from there.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
If you knw that then plz do let me knw too as i googled and binged a lot on that and final solution is to use a webservice or wcf. so we are using wcf. I am egarly waiting to know the solution.
|
|
|
|
|
I have no idea, I know that expecting email code to take a URL as an attachment is not going to work, and I know you're still asking in the wrong forum. Perhaps someone in the right forum, will know enough to help you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
can you please tell me in which fourm to ask this. I have posted it in silverlight, wcf and web devlopment too.
|
|
|
|
|
Well, spamming the whole site is just rude. Silverlight is the right forum. As I said in the outset, this has nothing to do with ASP.NET. The silverlight forum might be a little slower, you might wait a bit longer for a reply.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
That's Why I tried Here Any Ways. I didn't wanted to spam the site. I will try to remove my posts. Thanks for the Help.
|
|
|
|
|
Hi,
Have you tried this .. this is not my code .. I got it from net...
<br />
Dim client As New WebClient<br />
Dim strURL As String = "http://www.someurl.com/sendfile.php?file=myfile.gz"<br />
Dim strFilename As String = Server.MapPath("myfile.gz")<br />
client.DownloadFile(strURL, strFilename)
|
|
|
|
|
Server.Mappath is not supported in WCF
|
|
|
|
|
server.mappath is being used to generate a local path(local to the server) .. u can use absolute path.
|
|
|
|
|
sorry I didn't Get What You want to conevy. can you please explain with an example?
|
|
|
|
|
<br />
Dim client As New WebClient<br />
Dim strURL As String = "http://www.someurl.com/sendfile.php?file=myfile.gz"<br />
Dim strFilename As String = "c:\inetpub\wwwroot\my_app\images\myfile.gz"<br />
client.DownloadFile(strURL, strFilename)<br />
i wanted to suggested this workaround .. as server.mappath is not working.
|
|
|
|
|
and what will happen if I upload the web and then i would not be knowing what is the physical path I don't want a tempory solution. It should be ready to launch solution
|
|
|
|
|
Well.. im not aware of what wcf supports .. but there must be some way to find the current directory's path
|
|
|
|
|
May Be But I am not able to serch it till now.
|
|
|
|
|
Fine I got The Answer
The Solution Is Here
modified on Friday, September 11, 2009 9:27 AM
|
|
|
|
|
please help me out quickly
i had a dropdownlist in datagrid with list items from another datagrid while im clicking on the edit link the list items are dissappearing with empty dropdownlist i want list items to be updated when i click update along with other columns following is code for edit and dropdownlist...
protected void DataGid1_EditCommand(object source, DataGridCommandEventArgs e)
{
DataGid1.EditItemIndex = e.Item.ItemIndex;
BindData();
}
protected void DataGid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
SqlConnection cnn = new SqlConnection("Data Source=NETZOOM\\MADHUK_2005;Integrated Security=SSPI;Initial Catalog=master");
string sql = "select dept from dptmnt";
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand(sql, cnn);
cnn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DropDownList DropDownList1 = (DropDownList)((DataGridItem)e.Item).FindControl("DropDownList1");
ListItem li = new ListItem();
DropDownList1.Items.Add(li);
DropDownList1.DataSource = dr;
DropDownList1.DataValueField = "dept";
DropDownList1.DataTextField = "dept";
DropDownList1.DataBind();
}
}
|
|
|
|
|
OK, I can see that you're not working for money, you're just writing code to teach yourself. You should at least look at putting your connection strings into the web config, although this code would still be a long way short of a commercial standard, even if you did that.
I don't see the BindData method, I assume that's the method you want to fill the drop list when the user is editing data ? You have code to fill the drop lists, why do you have a drop list if the item is not being edited ? And why do you read your data source every time, including for rows that are not item rows ?
As I said, a lot of work here. I think you may want to buy a book and work through it, and abandon this test project for now.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
madhukk wrote: please help me out quickly
It's always amusing to me when people are rude enough to put a time limit on free help, don't post all the code needed to help them, and don't respond when people try to help.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
im new to asp... i wasted lot of time working on this please help about dropdownlist
|
|
|
|
|
I did help. I responded, and asked for more details, and made some comments. I assume you're doing some sort of self teaching project ? Why not just simplify it for now ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|