Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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.
 
 
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 27-Jun-13 19:32pm
Aravindba5.5K
Edited 27-Jun-13 19:48pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Aravindba at 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 at 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)

  Print Answers RSS
0 OriginalGriff 329
1 Maciej Los 290
2 Sergey Alexandrovich Kryukov 230
3 Shweta N Mishra 185
4 PIEBALDconsult 149
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,760


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 28 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100