Forgot your password?
Sign in with
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Python questions
View Java questions
All Message Boards...
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Design and Architecture
Internet of Things
C / C++ / MFC
ATL / WTL / STL
Objective-C and Swift
Hardware & Devices
Hosting and Servers
.NET (Core and Framework)
Site Bugs / Suggestions
Spam and Abuse Watch
The Insider Newsletter
The Daily Build Newsletter
Most Valuable Professionals
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
What is 'CodeProject'?
Ask a Question
Bugs and Suggestions
Article Help Forum
Comments by Adrian4263 (Top 44 by date)
Thanks for your answer, but the code u giving can't work as well.
Thanks for your answered.I solved it already.
I've checked,there is no reserved words, and I've tried your above method.It doesn't work for me also. Still have any solution?Anyway thanks for your reply.
Thanks your reply,but it doesn't work for me.
I check many times already,there is no reserved words in my Ms Access database.
Is okay.You Know Do Loop?
I tried already, samething.
Under msg got blue line, is it wrong?
I've tried,IO Exception was unhandled(The process cannot access the file 'C:\......py1.pdf' because it is being used by another process.)What is the problem?
You know how to delete the exported files(visual basic code)? Mean I click email button,the report will export to PDF file and attach send by email.What I need is the exported files will auto deleted after my email sent out. Is that clear?You can ask me,if my question not clear.Thx
Now is Crystal report export to PDF files, use PDFSharp it is work?
Seen its useless for me.Still have any solution?Except itextSharp.
Oh I see,actually I can create PDF files now,just cannot separate the page to each file.10 pages to 1 PDF files in 1 run.
You know what is the code? Itextsharp I never use before.
Actually I do not know the code for export separate PDF.I have to find it out now.
I did it,now what I mean is,for example: 10 people/10 pages,i want export the 10 pages to the 10 PDF files,I do not want 10 pages export into 1 PDF file.You get what I mean?Let say, now I have 3 pages need to send to 3 people,and each people will get 1 page,and now my problem is 3 pages export into 1 PDF file and sent to 3 people,that mean each people get it 3 pages.
Where this code should I put?
I've solved the Obj.Export error already.But I still have a small problem,that is PDF file,let' say 10 people,A1 to A10.I selected A1 ,come up 1 page,after that I click the email button it will export to PDF file first and attach send it out.This no problem.
If I select A1 to A3,it come up 3 pages,when I go click the email button,it should export 1 by 1 to the PDF file and send,but it wont,it combine the 3 pages in 1 PDF file.What is the problem?
Okay,finally I can send the email successful.I change he port from 465 to 25.Thanks you a lot.
But I still have a problem,for example,I have 10 people can select which is A1 to A10,after I select it will come up another page,example:I selected A1 to A1,it show 1 page,if only 1 page I click the email button it can sent successful.If I select A1 to A3,then it will come up 3 page,and I go click he email button it only can send the first page go out and then come out this following error:
Obj,Export<< this line of code error "The process cannot access the file 'C:\....\...\...\py1.pdf' Because it is being used by another process.
How to use debugger to find the error?Now I have 0 error,I just debug the program click email button,then pop up a MsgBox("failed to send email with the following error:" + e.Message)failure sending mail replace with the e.Message.Cannot consider as error right?
Should be add successful.My part 1 code is export and attach file,do you see any problem?
I already put the both place same email already,but it still the same,show me a msgbox >>failed to send email with the following error: Failure sending mail.
My credentials is
Smtp.Credentials = new NetworkCredential("email@example.com", "MyPassword"),like that can't?
I tried it,can't.I amend eid to ("firstname.lastname@example.org") it pop up a msgbox >>failed to send email with the following error: Failure sending mail.
Okay,I test the code just now.
msg.From = New MailAddress(eid)<<this line pop up msg said The parameter 'address' cannot be an empty string.
Parameter name: address.
SmtpClient Smtp = new SmtpClient("smtp.live.com", 465) where the code should me put?
Under the Dim Smtp As New SmtpClient("Smtp.live.com", 465)?
("MyEmail@hotmail.com", "MyPassword") or ("MyEmail@hotmail.com" and "MyPassword")?
Then my server should write ("Smtp.live.com", 465) p/s:465 is the port.
Please wait for awhile,I go try again see whether can run.
In the bracket write email address and password right? ("myemail@.hotmail.com", "password") need to put "" <<this?
I amend part 2 code,after that I want run the program,pop up there were build error,suddenly appear 12 error come up at the other part,its under the word got red line.For example, this page code have 11 pass <<word,11 pass word got the red line under the word.
The following is my email button code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dsd As New DataSet
Dim sql As String = "Select * from email"
Dim cmd As New SqlCommand(sql, connect)
dAdapter.SelectCommand = cmd
If dsd.Tables(0).Rows.Count > 0 Then
Dim type = dsd.Tables(0).Rows(0).Item("type")
Dim eid = dsd.Tables(0).Rows(0).Item("id").ToString.Trim
Dim pass = dsd.Tables(0).Rows(0).Item("pass").ToString.Trim
Dim port = dsd.Tables(0).Rows(0).Item("port").ToString.Trim
Dim server = dsd.Tables(0).Rows(0).Item("server").ToString.Trim
MsgBox("start to send email ...")
For i = 0 To dSet.Tables(0).Rows.Count - 1
Dim email As String = dSet.Tables(0).Rows(i).Item("email").ToString.Trim
If email <> "" Then
Dim id As String = dSet.Tables(0).Rows(i).Item("empid").ToString
Dim CrExportOptions As New ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
Dim crformatTypeOptions As New PdfRtfWordFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = _
CrExportOptions = obj.ExportOptions
crformatTypeOptions.FirstPageNumber = i
crformatTypeOptions.LastPageNumber = i
crformatTypeOptions.UsePageRange = True
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = crformatTypeOptions
Dim Smtp As New EASendMailObjLib.Mail
Smtp.LicenseCode = "TryIt"
Smtp.FromAddr = eid '"email@example.com"
Smtp.Subject = "aabb"
Smtp.BodyText = "aabb"
'' Add attachment from local disk
If Smtp.AddAttachment(pdfFile) <> 0 Then
MsgBox("Failed to add attachment with error:" & Smtp.GetLastErrDescription())
Smtp.ServerAddr = server '"smtp.gmail.com"
Smtp.ServerPort = port ' 465
'' detect SSL/TLS automatically
Smtp.UserName = eid '"firstname.lastname@example.org"
Smtp.Password = pass '"123"
If Smtp.SendMail() = 0 Then
'' MsgBox("email was sent successfully!")
Label1.Text = "1"
MsgBox("failed to send email with the following error:" & Smtp.GetLastErrDescription())
If Label1.Text = "1" Then
MsgBox("email was sent successfully!")
Label1.Text = ""
Roger,firstly, my email button code got 2 part,the part I shown above which is Part 2,just now I try the code got error, so i gonna show you the whole email button code.Hope you can help me solve the error.
Because the code is quite long. Is this reasonable?
email@example.com this is my email, can you inbox me,I got some question to ask you.Thanks
Okay,I got it.I go try and see,I think this is helpful and thanks you a lot :)
Yup,I know it.What I mean is where should I write the sender email address and password.
That mean I no need write any address in the msg.From address,because those I want to send mail to them is read from database.
Smtp.Credentials = New NetworkCredential(eid, pass),so I want replace my e-mail to eid and pass?
Okay. msg.From = New MailAddress(eid) <<The meail address is write my e-mail address is it?And Smtp.Credentials = New NetworkCredential (eid, pass)<< my id n password replace the NetworkCredential or replace in the bracket?
Okay,I have a question.What server part should I write?Smtp?
Do not need to use third-party library?Can Show me a simple example? Or modify my code above? Because the link you given,I'm not understand so much.Thanks
Thanks a lot,I think it is helpful.
Can you explain in clearly to me?I am not so understand the code that you wrote."Cpqa" is the file name right? Then what is "tbl_AF_xlsDataTDIdea"? and "cpqaAnswers"? Lets say, my file name is "excel" my table name is "excel1",then how I amend it?
I've tried already,even there got 5 method,but I cannot finish the steps,because in my SQL server I cannot find the import/export data button,SSIS package..
Mine one is SQL Server Management Studio Express.Is it same or different?
Last Updated 1 Jan 1900
All Rights Reserved.