|
I am facing a strange issue when sending a simple text mail with unicode characters.
This is the code which I am using
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "another test"
objMessage.From = "sender@test.com"
objMessage.To = "to@test.com"
objMessage.TextBody = "मानस"
objMessage.Send
Till, this point everything looks fine but as soon as I try to specify the charset of the body, the bosy content get corrupted and strage charcters appear in the email.
objMessage.BodyPart.CharSet = "utf-8"
That is, when I add the above line of code it simply does not work.
You may try to reproduce this by copying code into a vbs file.
Anyone has a clue?
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I am receiving an error from crystal reports that says i am missing parameters when i tell a report to print directly to a printer.
Here is the calling code.
Dim rdReport As CrystalDecisions.CrystalReports.Engine.ReportDocument
rdReport = PrintDocuments("Xbox Ticket")
'Main Report
rdReport.SetParameterValue("CustomerName", frm.cboCustomerName.Text.ToUpper)
rdReport.SetParameterValue("CustomerPhoneNumber", frm.lblPhoneNumber.Text.ToUpper)
'Details Subreport
rdReport.SetParameterValue("CashierName", Cashier, "Details")
rdReport.SetParameterValue("CustomerName", frm.cboCustomerName.Text.ToUpper, "Details")
rdReport.SetParameterValue("CustomerPhoneNumber", frm.lblPhoneNumber.Text.ToUpper, "Details")
rdReport.SetParameterValue("CopyField", "", "Details")
'Details2 Subreport
rdReport.SetParameterValue("CashierName", Cashier, "Details2")
rdReport.SetParameterValue("CustomerName", frm.cboCustomerName.Text.ToUpper, "Details2")
rdReport.SetParameterValue("CustomerPhoneNumber", frm.lblPhoneNumber.Text.ToUpper, "Details2")
rdReport.SetParameterValue("CopyField", "", "Details2")
rdReport.PrintOptions.PrinterName = My.Settings.ReportPrinter
rdReport.PrintToPrinter(1, True, 0, 0)
PrintDocuments is supposed to create a crystal report, prepopulate some parameter fields and then
return the report to the calling function to be displayed, printed, etc.
Here is the code for that.
Friend Function PrintDocuments(ByVal DocumentName As String) As CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim rdReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rdReport.Load(frmMain.ProgramDefault.ReportPath & "\" & DocumentName & ".rpt")
'Set report Logon Info
Dim LogInfo As CrystalDecisions.Shared.TableLogOnInfo
Dim crConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo()
With crConnectionInfo
.ServerName = DataServer.Server
.DatabaseName = DataServer.Database
If DataServer.Security Then
.IntegratedSecurity = DataServer.Security
Else
.IntegratedSecurity = DataServer.Security
.UserID = DataServer.UserName
.Password = DataServer.Password
End If
End With
LogInfo = New CrystalDecisions.Shared.TableLogOnInfo
LogInfo.ConnectionInfo = crConnectionInfo
Dim crTable As Table
For i As Integer = 0 To rdReport.Subreports.Count - 1
For Each crTable In rdReport.Subreports(i).Database.Tables
crTable.ApplyLogOnInfo(LogInfo)
Next crTable
Next
For Each crTable In rdReport.Database.Tables
crTable.ApplyLogOnInfo(LogInfo)
Next
'Look at parameter fields and fill in if found
Try
'Sub reports if found
For i As Integer = 0 To rdReport.Subreports.Count - 1
'if subreport does not have parameter fields don't worry about it
If rdReport.Subreports(i).ParameterFields Is Nothing Then Exit For
For l As Integer = 0 To rdReport.Subreports(i).ParameterFields.Count - 1
Select Case rdReport.Subreports(i).ParameterFields(l).Name
Case "CompanyName"
rdReport.Subreports(i).SetParameterValue("CompanyName", frmMain.ProgramDefault.CompanyName)
Case "CompanyStreet"
rdReport.Subreports(i).SetParameterValue("CompanyStreet", frmMain.ProgramDefault.CompanyStreet)
Case "CompanyCity"
rdReport.Subreports(i).SetParameterValue("CompanyCity", frmMain.ProgramDefault.CompanyCity)
Case "CompanyState"
rdReport.Subreports(i).SetParameterValue("CompanyState", frmMain.ProgramDefault.CompanyState)
Case "CompanyZip"
rdReport.Subreports(i).SetParameterValue("CompanyZip", frmMain.ProgramDefault.CompanyZip)
Case "CompanyPhone"
rdReport.Subreports(i).SetParameterValue("CompanyPhone", frmMain.ProgramDefault.CompanyPhone)
Case "CompanyFax"
rdReport.Subreports(i).SetParameterValue("CompanyFax", frmMain.ProgramDefault.CompanyFax)
Case "CompanyWeb"
rdReport.Subreports(i).SetParameterValue("CompanyWeb", frmMain.ProgramDefault.CompanyWeb)
Case "CashierName"
rdReport.Subreports(i).SetParameterValue("CashierName", Cashier)
End Select
Next
Next
Catch ex As Exception
End Try
'Main reports
For i As Integer = 0 To rdReport.ParameterFields.Count - 1
Select Case rdReport.ParameterFields(i).Name
Case "CompanyName"
rdReport.SetParameterValue("CompanyName", frmMain.ProgramDefault.CompanyName)
Case "CompanyStreet"
rdReport.SetParameterValue("CompanyStreet", frmMain.ProgramDefault.CompanyStreet)
Case "CompanyCity"
rdReport.SetParameterValue("CompanyCity", frmMain.ProgramDefault.CompanyCity)
Case "CompanyState"
rdReport.SetParameterValue("CompanyState", frmMain.ProgramDefault.CompanyState)
Case "CompanyZip"
rdReport.SetParameterValue("CompanyZip", frmMain.ProgramDefault.CompanyZip)
Case "CompanyPhone"
rdReport.SetParameterValue("CompanyPhone", frmMain.ProgramDefault.CompanyPhone)
Case "CompanyFax"
rdReport.SetParameterValue("CompanyFax", frmMain.ProgramDefault.CompanyFax)
Case "CompanyWeb"
rdReport.SetParameterValue("CompanyWeb", frmMain.ProgramDefault.CompanyWeb)
Case "CashierName"
rdReport.SetParameterValue("CashierName", Cashier)
End Select
Next
LogInfo = Nothing
crTable = Nothing
crConnectionInfo = Nothing
Return rdReport
End Function
i'm not sure but it seems that the parameters being set by the calling code are not being set properly.
Here is the original code, i modified it to be reusable in multiple different places but now i am running into this problem
Private Function PrintGameReceipt() As PrintingErrors
If Not frmMain.ProgramDefault.AllowPrinter Then Return PrintingErrors.OK
frmMain.Cursor = Cursors.WaitCursor
Try
Dim rdReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
'rdReport = PrintDocuments("Xbox Ticket")
'Dim rpath As String = RepPath
rdReport.Load(frmMain.ProgramDefault.ReportPath & "\" & "Xbox Ticket.rpt")
Dim LogInfo As CrystalDecisions.Shared.TableLogOnInfo
Dim crConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo()
With crConnectionInfo
.ServerName = DataServer.Server
.DatabaseName = DataServer.Database
If DataServer.Security Then
.IntegratedSecurity = DataServer.Security
Else
.IntegratedSecurity = DataServer.Security
.UserID = DataServer.UserName
.Password = DataServer.Password
End If
End With
LogInfo = New CrystalDecisions.Shared.TableLogOnInfo
LogInfo.ConnectionInfo = crConnectionInfo
Dim crTable As Table
For i As Integer = 0 To rdReport.Subreports.Count - 1
For Each crTable In rdReport.Subreports(i).Database.Tables
crTable.ApplyLogOnInfo(LogInfo)
Next crTable
Next
For Each crTable In rdReport.Database.Tables
crTable.ApplyLogOnInfo(LogInfo)
Next
rdReport.SetParameterValue("CompanyName", frmMain.ProgramDefault.CompanyName)
rdReport.SetParameterValue("CompanyStreet", frmMain.ProgramDefault.CompanyStreet)
rdReport.SetParameterValue("CompanyCity", frmMain.ProgramDefault.CompanyCity)
rdReport.SetParameterValue("CompanyState", frmMain.ProgramDefault.CompanyState)
rdReport.SetParameterValue("CompanyZip", frmMain.ProgramDefault.CompanyZip)
rdReport.SetParameterValue("CompanyPhone", frmMain.ProgramDefault.CompanyPhone)
rdReport.SetParameterValue("CompanyFax", frmMain.ProgramDefault.CompanyFax)
rdReport.SetParameterValue("CompanyWeb", frmMain.ProgramDefault.CompanyWeb)
rdReport.SetParameterValue("CashierName", Cashier)
rdReport.SetParameterValue("CustomerName", frm.cboCustomerName.Text.ToUpper)
rdReport.SetParameterValue("CustomerPhoneNumber", frm.lblPhoneNumber.Text.ToUpper)
'Details Section
rdReport.SetParameterValue("CompanyName", frmMain.ProgramDefault.CompanyName, "Details")
rdReport.SetParameterValue("CompanyStreet", frmMain.ProgramDefault.CompanyStreet, "Details")
rdReport.SetParameterValue("CompanyCity", frmMain.ProgramDefault.CompanyCity, "Details")
rdReport.SetParameterValue("CompanyState", frmMain.ProgramDefault.CompanyState, "Details")
rdReport.SetParameterValue("CompanyZip", frmMain.ProgramDefault.CompanyZip, "Details")
rdReport.SetParameterValue("CompanyPhone", frmMain.ProgramDefault.CompanyPhone, "Details")
rdReport.SetParameterValue("CompanyFax", frmMain.ProgramDefault.CompanyFax, "Details")
rdReport.SetParameterValue("CompanyWeb", frmMain.ProgramDefault.CompanyWeb, "Details")
rdReport.SetParameterValue("CashierName", Cashier, "Details")
rdReport.SetParameterValue("CustomerName", frm.cboCustomerName.Text.ToUpper, "Details")
rdReport.SetParameterValue("CustomerPhoneNumber", frm.lblPhoneNumber.Text.ToUpper, "Details")
rdReport.SetParameterValue("CopyField", "", "Details")
'Details2 Section
rdReport.SetParameterValue("CompanyName", frmMain.ProgramDefault.CompanyName, "Details2")
rdReport.SetParameterValue("CompanyStreet", frmMain.ProgramDefault.CompanyStreet, "Details2")
rdReport.SetParameterValue("CompanyCity", frmMain.ProgramDefault.CompanyCity, "Details2")
rdReport.SetParameterValue("CompanyState", frmMain.ProgramDefault.CompanyState, "Details2")
rdReport.SetParameterValue("CompanyZip", frmMain.ProgramDefault.CompanyZip, "Details2")
rdReport.SetParameterValue("CompanyPhone", frmMain.ProgramDefault.CompanyPhone, "Details2")
rdReport.SetParameterValue("CompanyFax", frmMain.ProgramDefault.CompanyFax, "Details2")
rdReport.SetParameterValue("CompanyWeb", frmMain.ProgramDefault.CompanyWeb, "Details2")
rdReport.SetParameterValue("CashierName", Cashier, "Details2")
rdReport.SetParameterValue("CustomerName", frm.cboCustomerName.Text.ToUpper, "Details2")
rdReport.SetParameterValue("CustomerPhoneNumber", frm.lblPhoneNumber.Text.ToUpper, "Details2")
rdReport.SetParameterValue("CopyField", "", "Details2")
rdReport.PrintOptions.PrinterName = My.Settings.ReportPrinter
rdReport.PrintToPrinter(1, True, 0, 0)
Catch ex As Exception
frmMain.Cursor = Cursors.Default
Dim vd As New VDialog()
With vd
.Buttons = New VDialogButton() {New VDialogButton(VDialogResult.OK)}
.WindowTitle = "Print Error"
.MainInstruction = "Print Error"
.MainIcon = VDialogIcon.Error
.Content = "Error Printing Receipts"
.FooterIcon = VDialogIcon.Error
.FooterText = "Print Error"
.ExpandedControlText = "Hide Info "
.CollapsedControlText = "Show Info "
.ExpandedInformation = "Extra Information" & vbCrLf & ControlChars.CrLf & ex.Message
.ExpandFooterArea = True
.ExpandedByDefault = False
.Show()
End With
WriteToEventLog("Error Printing Receipts (Game Form Class): " & vbCrLf & ex.Message, , EventLogEntryType.Error, , 227)
Return PrintingErrors.BadData
End Try
frmMain.Cursor = Cursors.Default
Return PrintingErrors.OK
End Function
Any help would be greatly appreciated.
modified on Friday, July 24, 2009 9:43 AM
|
|
|
|
|
First this app is an intranet WebForms app.
I have displayed bond data in a datalist with additional textboxes in the datalist grid for data entry. I'm actually looking for a better solution than the one that is currently implemented.
Currnetly: textbox1 is txtQty, textbox2 is txtRate, label1 is lblTotal and button1 is btnCompute. The user enters data in txtQty and txtRate click on btnCompute thus invoke datalist_ItemCommand and retrieve the txtQty & txtRate using the .FindCommand for the current row, then compute the lblTotal and move to the next row. This subroutine gets access to "byval e as System.Web.UI.WebControls.DatalistItemEventArgs" which makes the current row available and life is great, except the dataentry operator has to click the compute button.
I would like to get rid of the button and set up the app to use the OnTextChange Event of the textbox. this is a problem because it uses "byval e as System.EventArgs" for its argument and the current datalist row is not available.
Can anybody show me how to get the current row of the datalist for the textbox that triggered the OnTextChange event?
Thanks, Chuck
|
|
|
|
|
Hi there Vb community, im looking for help or an example for the following:
Im looking to create a program that starts up with user login, once users login they would be taken to the latest news etc. Using a tab control or something similar the user can click on mail/jobs specific to that user only.
If your slightly confused, i'd like something like this for employees.
Any help or advise would be great thanks,
Malcom
|
|
|
|
|
Sounds more like a corporate Portal than a VB (windows) applicaiton.
Before you go and build something, take a look at Dot Net Nuke (DNN).
http://www.dotnetnuke.com/[^]
Take the time to learn about it and you will be amazed at what you get for free!
I implemented it at my previous company and it works really well.
david
|
|
|
|
|
Sounds more like an assignment to me.
|
|
|
|
|
Hi if you are familiar with Visual basic then it's so easy to creat that kind of software .
At first your must to know all atribute . Make a design of data base
E-R diagram depand on your requrement.
First : you design the diagram and make relation with all entity (
Entity-Relationship Model )
Second : Make form depand on those table you made and relationship of model ( You must to make a table of user name and password and make relation with users )
Then it will be more easy.
If You want source code or if you want sample Please write would try to reply you as soon as possible
Good luck
|
|
|
|
|
Thanks for replying, i managed to get help. Thanks again,
Malcom
|
|
|
|
|
I've looked at several examples (not the database piece yet for capturing the "Yes" instances) and put together the code listed below. In a prior version of code also in the ItemSend Object the user is presented with the message box like I want and if they select "No" the E-Mail message is not sent.
However, when I tried to modify the code (see below) I get the Microsoft VB error:
"Run-time error '424' Object Required
Can someone help me correct my code statement and also let me know if I have the correct syntax for searching the body of the E-Mail message. I created a test E-Mail message with "Joe" in the body of the message. If I can't figure out the database piece, is the only option I have hard coding the names of all the restricted employees?
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim olMail As Outlook.MailItem
Set olMail = olapp.CreateItem(olMailItem)
Dim blnExecute As Boolean
If InStr(olMail.Body, "Joe") <> 0 Then
blnExecute = CBool(MsgBox("You are sending " & _
"or forwarding an E-Mail message from a " & _
"restricted employee, do you wish to " & _
"continue?", vbYesNo, "Rule Execution") = vbYes)
If blnExecute = True Then
'Eventually want some code to capture that
'the end-user chose to send the E-Mail
'message.
ElseIf blnExecute = False Then
Cancel = True 'this will cancel the send
End If
End If
Thanks for your help as always.
axla
|
|
|
|
|
Hi, I just need code that I have 4 column A B C D in Ms-Excel
In VB Form I had list first 2 columns value in Combo Box
& 3rd column is also combo Box containing “Auto & Manual”
4th column is sum of column A & B
In VB form there is Text Box in which the Answer or the Sum “column D” must be shown
But I don’nt know what code use for Text box or Auto Manual combo box to display column D in Text box
Thanks & regards:
Muhammad Ata-ul-haq Sultani
|
|
|
|
|
Plz post your problem in detail, so that i could solve it. It is not too hard to read data or record from excel sheet.
|
|
|
|
|
In short when I select Auto from combo box I need the values(which are in column D in excel) in text Box
|
|
|
|
|
hi, im new-ish to vb
im currently pseudocoding a program for sorting some data. the data is pulled from file or database, then compared against some fields in another file or db, then put into an array. the initial data has 5 fields, the second has 8, and the result has 2 fields. at the moment its 400+ entries with 40-60 groups with 4-8 comparisons for each
what i am endlessly confused about is if a 5D array "appears" the same as a db table with 5 columns or if it more closely resembles a black hole (so i can visualise it a bit easier) and whether it would be easier to code 5 x 2D arrays for the data and another 8 x 2D for the tests
oh, and which method is more efficient
-N
note: i have completed the file>array bit and can compare two arrays
|
|
|
|
|
IMO a database table is a one-dimensional array holding rows; each row holds fields of different types, something an array isn't capable of in most languages.
In C#, C/C++, or VB.NET a row could be represented by a class or struct, where each field corresponds to one field of the datatable row.
Do not use multi-dimensional arrays if you don't really need them, and don't use parallel one-dimensional arrays either: use more structured data, as in an array of structs/classes.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
thats very useful
thanks for the fast reply
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
This is a stub version of the actual problem.
Here are two files. Form1.vb, which looks like this:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myIKGrid As New IKGrid
myIKGrid.Columns(0).Caption = "English"
myIKGrid.Columns(0) = "Zero"
End Sub
End Class
You cannot modify Form1 for any reason whatsoever.
The other file is IKGrid.vb. It looks like this:
Public Class IKGrid
Public Property Columns(ByVal s As Short) As IKColumn
Get
Return Nothing
End Get
Set(ByVal value As IKColumn)
End Set
End Property
End Class
Public Class IKColumn
Public Property Caption() As String
Get
Return ""
End Get
Set(ByVal value As String)
End Set
End Property
End Class
You can modify IKGrid any way you please.
Anyway, this code results in a compile error. The line:
myIKGrid.Columns(0) = "Zero"
causes
Value of type 'String' cannot be converted to 'IKColumn'
So, how can you modify the IKGrid file so that the String CAN be converted to an IKColumn? The project doesn't need to do anything useful, it just needs to be able to compile without errors.
|
|
|
|
|
i_kant_spel wrote: The project doesn't need to do anything useful
Interesting prospect.
From myIKGrid.Columns(0) = "Zero" it would seem IKGrid.Columns[] is a string array, however you can't get myIKGrid.Columns(0).Caption = "English" right since a string doesn't have a Caption property.
Hence, IKGrid.Columns must be a type that has a Caption property, and has an override for the = operator.
The remainder is left as your homework.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Override for the = operator? Only in C++ where nothing means anything because everything can be overriden. There are not overrides for assignment in .NET (or VB6 for that matter), though with default properties, it could sometimes look that way.
|
|
|
|
|
Now you killed the homework completely!?
there is an "operator implicit" in C# that would let you cast automatically, don't know how VB.NET stands on this.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
It's got to be possible somehow. The original project uses commercial libraries, which I don't have access to at this time. I'm trying to create dummy classes. For the time being, I don't need the functionality of the real classes. I just need the existing code to compile correctly as it is.
Whatever type IKGrid.Columns(0) returns, it definitely has a "caption" property and it does something that makes it possible to assign a String to it with the equals operator. But I still have no idea how that's done. I've looked into overloading operators in VB.NET, but I can't find information regarding the equals sign as an assignor, only as an equality tester.
|
|
|
|
|
There's a bit of a disconnect between your initial question and its restrictions. Either you can recompile the form class, which means you can change it to just use the caption property, or you can't recompile it and you can't do anything to IKGrid either because the form has already bound to it. (Well, you may be able to change some things, but nothing that will make your situation work.)
Regardless, Luc and I have dropped some hints about how to do what you want in other posts in the thread.
|
|
|
|
|
Well, yes there are conversion operators I suppose (Widening Operator CType would be equivalent to implicit, I believe)
Personally, my solution is fix the code in the form, but if the situation doesn't allow, then I guess there are plenty of ways to get around it. Though if it's not homework, one wonders how it compiled in the first case.......
|
|
|
|
|
Adding a Widening Operator CType to the dummy class worked. So I guess it compiled in the first place because the class in the commercial library does something similar.
|
|
|
|
|
Unless I am missing something, doesn't the Caption property of the IKColumn class need to be set as the default property?
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|