Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
How can I create an Excel and PDF file on domain server when it has a lot of security?

My name is muhammad irfan asnari
I am from Pakistan and I want to ask that I had made a website in which contact us page and then client will fill the form and submit it so behind them a file create in format of PDF and then it will be send to a particular emails address.
I would like to ask that when I submit so its work very good on my local host not on domain there is security problem.

Please any one tell me how should I create a file.
Posted
Updated 12-Nov-11 1:11am
v2
Comments
irfanansari 13-Nov-11 2:30am    
Imports System.Net.Mail
Imports System
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Partial Class CONTACT
Inherits System.Web.UI.Page
Dim c As New Class1
Dim MAIL As New MailMessage
Dim s As String
Dim path As String

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35)
path = Server.MapPath("contact.pdf")
' Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream("C:\sample.pdf", FileMode.Create))

PdfWriter.GetInstance(doc, New FileStream(Request.PhysicalApplicationPath + "\contact.pdf", FileMode.Create))

doc.Open()
Dim table = New PdfPTable(2)

Dim cell As New PdfPCell

cell = New PdfPCell(New Phrase("THIS IS CONTACT INFORATION WHICH IS FIELD BY USER"))
cell.Colspan = 2

cell.HorizontalAlignment = 1


table.AddCell(cell)

table.AddCell("First Name:")

table.AddCell(txtfname.Text)

table.AddCell("Last Name: ")
table.AddCell(txtlname.Text)

table.AddCell("Address:")
table.AddCell(txtaddress.Text)

table.AddCell("Apt#:")
table.AddCell(txtapt.Text)

table.AddCell("Postal Code: ")
table.AddCell(txtpostalcod.Text)

table.AddCell("City: ")
table.AddCell(txtcity.Text)

table.AddCell("*Province:")
table.AddCell(DropDownList1.Text)

table.AddCell("Country: ")
table.AddCell(DropDownList2.Text)

table.AddCell("Phone: ")
table.AddCell(txtphone.Text & vbNewLine & s)

table.AddCell("E-mail Address:")
table.AddCell(txtemail.Text)

table.AddCell("Campus of Interest: ")
table.AddCell(DropDownList3.Text)

table.AddCell("Program of Interest:")
table.AddCell(DropDownList4.Text)


table.AddCell("How did you hear about us?: ")
table.AddCell(DropDownList5.Text)

table.AddCell("CONTACT FORM FIELD DATE AND TIME")
table.AddCell(Date.Now)

doc.Add(table)



'Response.Redirect("~\sample.pdf")

doc.Close()
Try
MAIL.From = New MailAddress("irfanansari90@gmail.com", "MUHAMAD IRFAN ANSARI")
MAIL.To.Add("irfanansari85@yahoo.com,ansari@harisimad.com")
MAIL.Subject = "ALL INFORATION CONNTACT US"
MAIL.Body = "First Name :-" & vbTab & txtfname.Text & vbNewLine & _
"Last Name:-" & vbTab & txtlname.Text & vbNewLine & _
"Address:-" & vbTab & txtaddress.Text & vbNewLine & _
"APT #:-" & vbTab & txtapt.Text & vbNewLine & _
"Postal Code:-" & vbTab & txtlname.Text & vbNewLine & _
"City:-" & vbTab & txtlname.Text & vbNewLine & _
"Province:-" & vbTab & DropDownList1.Text & vbNewLine & _
"Country:-" & vbTab & DropDownList2.Text & vbNewLine & _
"City:-" & vbTab & txtcity.Text & vbNewLine & _
"Phone:-" & vbTab & txtphone.Text & s & vbNewLine & _
"E-mail Address:-" & vbTab & txtemail.Text & vbNewLine & _
"Campus of Interest:-" & vbTab & DropDownList3.Text & vbNewLine & _
"Program of Interest:-" & vbTab & DropDownList4.Text & vbNewLine & _
"How did you hear about us?:-" & vbTab & DropDownList5.Text

' eMAIL SEND WITH ATTACHMENT
MAIL.Attachments.Add(New Attachment(path))

Dim smtp As New SmtpClient("smtp.gmail.com")
smtp.Port = 587
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("irfanansari90@gmail.com", "tabletable")
smtp.Send(MAIL)
Catch ex As Exception
Session("a") = "THERE IS NO INTERNET CONNECTION"
End Try
Try
c.connection()
c.insert(txtfname, txtlname, txtad

For creating Excel files try this : http://epplus.codeplex.com/[^]

For PDF files you can try these :
http://www.websupergoo.com/abcpdf-1.htm[^]

http://www.asppdf.com/[^]

http://www.pdftron.com/pdfnet/[^]
 
Share this answer
 
Comments
irfanansari 12-Nov-11 7:21am    
i Had A Create A File In PDF Formate it not allow on server so please advice me how i can create a file on domain which is not give me permisstion
Mehdi Gholam 12-Nov-11 7:27am    
What are you using to create the pdf file?
irfanansari 13-Nov-11 2:30am    
Imports System.Net.Mail
Imports System
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Partial Class CONTACT
Inherits System.Web.UI.Page
Dim c As New Class1
Dim MAIL As New MailMessage
Dim s As String
Dim path As String

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35)
path = Server.MapPath("contact.pdf")
' Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream("C:\sample.pdf", FileMode.Create))

PdfWriter.GetInstance(doc, New FileStream(Request.PhysicalApplicationPath + "\contact.pdf", FileMode.Create))

doc.Open()
Dim table = New PdfPTable(2)

Dim cell As New PdfPCell

cell = New PdfPCell(New Phrase("THIS IS CONTACT INFORATION WHICH IS FIELD BY USER"))
cell.Colspan = 2

cell.HorizontalAlignment = 1


table.AddCell(cell)

table.AddCell("First Name:")

table.AddCell(txtfname.Text)

table.AddCell("Last Name: ")
table.AddCell(txtlname.Text)

table.AddCell("Address:")
table.AddCell(txtaddress.Text)

table.AddCell("Apt#:")
table.AddCell(txtapt.Text)

table.AddCell("Postal Code: ")
table.AddCell(txtpostalcod.Text)

table.AddCell("City: ")
table.AddCell(txtcity.Text)

table.AddCell("*Province:")
table.AddCell(DropDownList1.Text)

table.AddCell("Country: ")
table.AddCell(DropDownList2.Text)

table.AddCell("Phone: ")
table.AddCell(txtphone.Text & vbNewLine & s)

table.AddCell("E-mail Address:")
table.AddCell(txtemail.Text)

table.AddCell("Campus of Interest: ")
table.AddCell(DropDownList3.Text)

table.AddCell("Program of Interest:")
table.AddCell(DropDownList4.Text)


table.AddCell("How did you hear about us?: ")
table.AddCell(DropDownList5.Text)

table.AddCell("CONTACT FORM FIELD DATE AND TIME")
table.AddCell(Date.Now)

doc.Add(table)



'Response.Redirect("~\sample.pdf")

doc.Close()
Try
MAIL.From = New MailAddress("irfanansari90@gmail.com", "MUHAMAD IRFAN ANSARI")
MAIL.To.Add("irfanansari85@yahoo.com,ansari@harisimad.com")
MAIL.Subject = "ALL INFORATION CONNTACT US"
MAIL.Body = "First Name :-" & vbTab & txtfname.Text & vbNewLine & _
"Last Name:-" & vbTab & txtlname.Text & vbNewLine & _
"Address:-" & vbTab & txtaddress.Text & vbNewLine & _
"APT #:-" & vbTab & txtapt.Text & vbNewLine & _
"Postal Code:-" & vbTab & txtlname.Text & vbNewLine & _
"City:-" & vbTab & txtlname.Text & vbNewLine & _
"Province:-" & vbTab & DropDownList1.Text & vbNewLine & _
"Country:-" & vbTab & DropDownList2.Text & vbNewLine & _
"City:-" & vbTab & txtcity.Text & vbNewLine & _
"Phone:-" & vbTab & txtphone.Text & s & vbNewLine & _
"E-mail Address:-" & vbTab & txtemail.Text & vbNewLine & _
"Campus of Interest:-" & vbTab & DropDownList3.Text & vbNewLine & _
"Program of Interest:-" & vbTab & DropDownList4.Text & vbNewLine & _
"How did you hear about us?:-" & vbTab & DropDownList5.Text

' eMAIL SEND WITH ATTACHMENT
MAIL.Attachments.Add(New Attachment(path))

Dim smtp As New SmtpClient("smtp.gmail.com")
smtp.Port = 587
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("irfanansari90@gmail.com", "tabletable")
smtp.Send(MAIL)
Catch ex As Exception
Session("a") = "THERE IS NO INTERNET CONNECTION"
End Try
Try
c.connection()
c.insert(txtfname, txtlname, txtad
Mehdi Gholam 13-Nov-11 14:02pm    
Create a folder on your server with read and write permissions (like your temp folder) and write your files there.
irfanansari 14-Nov-11 3:50am    
but how please tell me please or is there any other way so please tell me any other object or other way to do this please
Check with your domain server if you have problems. Uses another server if they don't want to help you. Or create your file in memory if they are not too big.
 
Share this answer
 
Comments
irfanansari 13-Nov-11 2:29am    
please tell me is there any way that i can create a pdf file on my purchase domain
irfanansari 13-Nov-11 2:30am    
Imports System.Net.Mail
Imports System
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Partial Class CONTACT
Inherits System.Web.UI.Page
Dim c As New Class1
Dim MAIL As New MailMessage
Dim s As String
Dim path As String

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35)
path = Server.MapPath("contact.pdf")
' Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream("C:\sample.pdf", FileMode.Create))

PdfWriter.GetInstance(doc, New FileStream(Request.PhysicalApplicationPath + "\contact.pdf", FileMode.Create))

doc.Open()
Dim table = New PdfPTable(2)

Dim cell As New PdfPCell

cell = New PdfPCell(New Phrase("THIS IS CONTACT INFORATION WHICH IS FIELD BY USER"))
cell.Colspan = 2

cell.HorizontalAlignment = 1


table.AddCell(cell)

table.AddCell("First Name:")

table.AddCell(txtfname.Text)

table.AddCell("Last Name: ")
table.AddCell(txtlname.Text)

table.AddCell("Address:")
table.AddCell(txtaddress.Text)

table.AddCell("Apt#:")
table.AddCell(txtapt.Text)

table.AddCell("Postal Code: ")
table.AddCell(txtpostalcod.Text)

table.AddCell("City: ")
table.AddCell(txtcity.Text)

table.AddCell("*Province:")
table.AddCell(DropDownList1.Text)

table.AddCell("Country: ")
table.AddCell(DropDownList2.Text)

table.AddCell("Phone: ")
table.AddCell(txtphone.Text & vbNewLine & s)

table.AddCell("E-mail Address:")
table.AddCell(txtemail.Text)

table.AddCell("Campus of Interest: ")
table.AddCell(DropDownList3.Text)

table.AddCell("Program of Interest:")
table.AddCell(DropDownList4.Text)


table.AddCell("How did you hear about us?: ")
table.AddCell(DropDownList5.Text)

table.AddCell("CONTACT FORM FIELD DATE AND TIME")
table.AddCell(Date.Now)

doc.Add(table)



'Response.Redirect("~\sample.pdf")

doc.Close()
Try
MAIL.From = New MailAddress("irfanansari90@gmail.com", "MUHAMAD IRFAN ANSARI")
MAIL.To.Add("irfanansari85@yahoo.com,ansari@harisimad.com")
MAIL.Subject = "ALL INFORATION CONNTACT US"
MAIL.Body = "First Name :-" & vbTab & txtfname.Text & vbNewLine & _
"Last Name:-" & vbTab & txtlname.Text & vbNewLine & _
"Address:-" & vbTab & txtaddress.Text & vbNewLine & _
"APT #:-" & vbTab & txtapt.Text & vbNewLine & _
"Postal Code:-" & vbTab & txtlname.Text & vbNewLine & _
"City:-" & vbTab & txtlname.Text & vbNewLine & _
"Province:-" & vbTab & DropDownList1.Text & vbNewLine & _
"Country:-" & vbTab & DropDownList2.Text & vbNewLine & _
"City:-" & vbTab & txtcity.Text & vbNewLine & _
"Phone:-" & vbTab & txtphone.Text & s & vbNewLine & _
"E-mail Address:-" & vbTab & txtemail.Text & vbNewLine & _
"Campus of Interest:-" & vbTab & DropDownList3.Text & vbNewLine & _
"Program of Interest:-" & vbTab & DropDownList4.Text & vbNewLine & _
"How did you hear about us?:-" & vbTab & DropDownList5.Text

' eMAIL SEND WITH ATTACHMENT
MAIL.Attachments.Add(New Attachment(path))

Dim smtp As New SmtpClient("smtp.gmail.com")
smtp.Port = 587
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("irfanansari90@gmail.com", "tabletable")
smtp.Send(MAIL)
Catch ex As Exception
Session("a") = "THERE IS NO INTERNET CONNECTION"
End Try
Try
c.connection()
c.insert(txtfname, txtlname, txtad
Agree with Philippe Mori.

BTW you should have mentioned the error message in your question. Anyway check these articles for reference.

Allow your ASP.NET to Access your Resources[^]
Howto: (Almost) Everything In Active Directory via C#[^]
NT Security Classes for .NET[^]
 
Share this answer
 
Comments
irfanansari 13-Nov-11 2:30am    
please tell me is there any way that i can create a pdf file on my purchase domain
please see my website and tell me please my code is this
Imports System.Net.Mail
Imports System
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Partial Class CONTACT
Inherits System.Web.UI.Page
Dim c As New Class1
Dim MAIL As New MailMessage
Dim s As String
Dim path As String

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35)
path = Server.MapPath("contact.pdf")
' Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream("C:\sample.pdf", FileMode.Create))

PdfWriter.GetInstance(doc, New FileStream(Request.PhysicalApplicationPath + "\contact.pdf", FileMode.Create))

doc.Open()
Dim table = New PdfPTable(2)

Dim cell As New PdfPCell

cell = New PdfPCell(New Phrase("THIS IS CONTACT INFORATION WHICH IS FIELD BY USER"))
cell.Colspan = 2

cell.HorizontalAlignment = 1


table.AddCell(cell)

table.AddCell("First Name:")

table.AddCell(txtfname.Text)

table.AddCell("Last Name: ")
table.AddCell(txtlname.Text)

table.AddCell("Address:")
table.AddCell(txtaddress.Text)

table.AddCell("Apt#:")
table.AddCell(txtapt.Text)

table.AddCell("Postal Code: ")
table.AddCell(txtpostalcod.Text)

table.AddCell("City: ")
table.AddCell(txtcity.Text)

table.AddCell("*Province:")
table.AddCell(DropDownList1.Text)

table.AddCell("Country: ")
table.AddCell(DropDownList2.Text)

table.AddCell("Phone: ")
table.AddCell(txtphone.Text & vbNewLine & s)

table.AddCell("E-mail Address:")
table.AddCell(txtemail.Text)

table.AddCell("Campus of Interest: ")
table.AddCell(DropDownList3.Text)

table.AddCell("Program of Interest:")
table.AddCell(DropDownList4.Text)


table.AddCell("How did you hear about us?: ")
table.AddCell(DropDownList5.Text)

table.AddCell("CONTACT FORM FIELD DATE AND TIME")
table.AddCell(Date.Now)

doc.Add(table)



'Response.Redirect("~\sample.pdf")

doc.Close()
Try
MAIL.From = New MailAddress("irfanansari90@gmail.com", "MUHAMAD IRFAN ANSARI")
MAIL.To.Add("irfanansari85@yahoo.com,ansari@harisimad.com")
MAIL.Subject = "ALL INFORATION CONNTACT US"
MAIL.Body = "First Name :-" & vbTab & txtfname.Text & vbNewLine & _
"Last Name:-" & vbTab & txtlname.Text & vbNewLine & _
"Address:-" & vbTab & txtaddress.Text & vbNewLine & _
"APT #:-" & vbTab & txtapt.Text & vbNewLine & _
"Postal Code:-" & vbTab & txtlname.Text & vbNewLine & _
"City:-" & vbTab & txtlname.Text & vbNewLine & _
"Province:-" & vbTab & DropDownList1.Text & vbNewLine & _
"Country:-" & vbTab & DropDownList2.Text & vbNewLine & _
"City:-" & vbTab & txtcity.Text & vbNewLine & _
"Phone:-" & vbTab & txtphone.Text & s & vbNewLine & _
"E-mail Address:-" & vbTab & txtemail.Text & vbNewLine & _
"Campus of Interest:-" & vbTab & DropDownList3.Text & vbNewLine & _
"Program of Interest:-" & vbTab & DropDownList4.Text & vbNewLine & _
"How did you hear about us?:-" & vbTab & DropDownList5.Text

' eMAIL SEND WITH ATTACHMENT
MAIL.Attachments.Add(New Attachment(path))

Dim smtp As New SmtpClient("smtp.gmail.com")
smtp.Port = 587
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("irfanansari90@gmail.com", "tabletable")
smtp.Send(MAIL)
Catch ex As Exception
Session("a

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