Click here to Skip to main content
11,929,232 members (62,321 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET
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 = ""
        mail.[To] = ""
        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"

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

Posted 27-Jun-13 19:32pm
Edited 27-Jun-13 19:48pm

1 solution

Rate this: bad
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
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
at the bottom if u click on 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

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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 28 Jun 2013
Copyright © CodeProject, 1999-2015
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