Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hai
I have website in server(i.e iis),if i use outlook in server it not work,so i use SMPT mail transfer ,in that how to attach file,here i past code in that pls modify my code to attach file
and mail also not send ,it show error like transfer mail failed.
VB
Imports System.Web.UI.HtmlControls
Imports System.Web.UI
Imports System.Web.UI.WebControls

        Dim mail As New System.Web.Mail.MailMessage()
       ' Dim att As System.Web.Mail.MailAttachment()
        mail.From = "aravind@ambersoft.net"
        mail.[To] = "aravind@ambersoft.net"
        mail.Subject = "Here goes the Subject"
        mail.Body = "Here comes the body..."
        ' mail.Attachments(att)
       ' att = "C:\a.txt"
       ' mail.Attachments.Add(att)
        System.Web.Mail.SmtpMail.SmtpServer = "smtp.server.of.customer"
        System.Web.Mail.SmtpMail.Send(mail)



the above code i try,but attachment not work so i comment that line,pls modify that to attach file also and send mail also.

Note: i have this website in iis,not in local drive,so pls reply me it will work on iis also

Regards
Aravind
Posted
Updated 27-Jun-13 18:48pm
v2

1 solution

You can refer below

att = "C:\a.txt"
If Not String.IsNullOrEmpty(att) Then
	Using sm As New MemoryStream(Encoding.UTF8.GetBytes(att))
		mail.Attachments.Add(New Attachment(sm, Path.GetFileName(att)))
	End Using
End If
 
Share this answer
 
Comments
Aravindba 28-Jun-13 6:39am    
Hai thank you for ur reply,my need is different,pls forgot this one, actually my need is if clike button in web site it will open outlook window with add all fields like to address,subject,file attachment, from address automatically appear when create profile in outlook so dont brother from address, i will write code for outlook and work in local drive ,if i publish in iis(server) it not work,it give some permission error.

u can visit this page http://www.telerik.com/help/windows-8-html/chart-donut-series.html
at the bottom if u click on documentation@telerik.com link ,it open outlook same like i want,it open outlook window and user click send button in outlook.
pls reply me

Note:u try in iis not in local drive,local drive it work

Regards
Aravind
Mahesh Bailwal 28-Jun-13 6:59am    
Please mark this question as solved and post new question of your new requirement so that its visible to everyone and you can have better answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900