VS 2010 - String As Attachment
Nov 21, 2011I don't think this is possible but in case if it's possible, I would like to know if it's possible to attach a string, as an attachment and send it by email. (without creating any file.
View 1 RepliesI don't think this is possible but in case if it's possible, I would like to know if it's possible to attach a string, as an attachment and send it by email. (without creating any file.
View 1 RepliesI have coded random string as below and i want to convert it to qr code , then send to email automatically...
Dim chars As String = "Test1"
Dim qr As String = ""
Dim r As New Random()
Dim i As Integer
For i = 1 To 5
qr += chars.Substring(r.Next(chars.Length), 1)
Next
I am using Microsoft Outlook interop to display email with filled out email addresses and attachment.
Now Everything works fine except one problem with Attachment. The problem is that I am getting attachment from other methods as Byte Array and if I am not able to pass this byte array as attachment to outlook object's attachment. I believe tt requires a physical file from disk. how can I conver this Byte Array to attach it with Outlook.Attachment object?
Here is my code. In this code, for now I hardcoded attachment from "C: est.txt" but I need to change it to Byte Array, I tried but its throwing error.how can I change it to Byte Array?
##############################################################
[Code]....
I have a string "10/15/2010" I want to split this string into 10, 15, 2010 using c#, in VS 2010. i am not sure how to do this.
View 9 RepliesI'm sure it's possible, but i don't know how to do it :I have CONTENT declared as String , in CONTENT i have texts, but i would like only to select the texts >> from the beigning of the string until it finds the word "STOPHERE".And then from the end of "STOPHERE" until the end of the text.As it's not always at the same place i coudn't use .SubString
View 6 RepliesI am able to populate a text box with a long string. This string is a collection of email addresses, I am wondering how I can split this string so that I am able to get the individual email addresses? If I select multiple email addresses it come through like Example: test1@test.comtest2@test.com in the one text box how could I split this so I could get test1@test.com in one text box and test2@test.com in another?
Code:
Protected Sub BtnEmailList_Click(sender As Object, e As System.EventArgs) Handles BtnEmailList.Click
' StringBuilder object
Dim str As New StringBuilder()
' Select the checkboxes from the GridView control
For i As Integer = 0 To GrdVwClassEmail.Rows.Count - 1
Dim row As GridViewRow = GrdVwClassEmail.Rows(i)
[Code].....
I am trying to get all the words in a string using a regular expression.When I use this expression in javascript, it works, but when I try it in the .Net code I get the whole string.this is my code.Is my regular expression wrong or am I using the wrong method?
Code:
Dim myRegex As New Regex("/([a-zA-Z]){1,1}([a-z])+/g")
Dim str() As String = myRegex.Split(text)
I'm stuck getting a value from a textbox in code behind. I have tried
Code:
string s2 = txtEmployeeNr.Text;
and
Code:
string s1 = Server.HtmlEncode(txtEmployeeNr.Text);
And just get an empty string.
I have used the last one before with good results.
I have a maskededit extender
Code:
TargetControlID="dateTextBox"
Mask="99/99/9999 99:99"
MessageValidatorTip="true"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="DateTime"
[Code] ....
So the input format looks like this 12/23/2012 12:12 AM
And I would like to convert this as datetime so i tried to do
Code:
Dim ab As DateTime
ab = DateTime.Parse(dateTextBox.Text)
But it's showing me an error
Code:
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.DateTime.Parse(String s)
at admin_trackadd.saveButton_Click(Object sender, EventArgs e)
How can I convert the english date 10/29/2010 or any language date to user culture date format
I am using the following code
CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
cultureInfo.DateTimeFormat.
string lng = cultureInfo.TwoLetterISOLanguageName;
DateTime dateTime = DateTime.Parse("10/29/2010", cultureInfo);
but it throws error when I try to parse it.
I am building a webservice that reads some HTML source code from a website and sends it back to the client. The service however is failing to send the data because it is too large. I keep getting this error:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter [URL]..... The InnerException message was 'There was an error deserializing the object of type iRacingForumServiceTest.ForumService.GetForumListResponseBody. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 153, position 247.'. Please see InnerException for more details.
I have been googling this problem for ages and I cannot figure out how to apply the answers I keep finding.
The problem is simple: the default configuration doesn't allow such large strings. I just don't know how to change this. All I keep finding is things related to WCF, I'm not sure if that applies for me.
What I keep finding is that I need to change the web.config file in various ways. However I cannot figure out where I need to put the config sections. I've tried everything but without a complete web.config file example I can't get it to work
Here is my current web.config of the server:
Code:
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings/>
<system.web>
[Code] ....
I found this piece to add to it:
Code:
<system.serviceModel>
<services>
<service name="ForumService">
<endpoint address=""
binding="basicHttpBinding"
[Code] ....
I figured out where to put it without getting errors (just as a child of the <configuration> element), but it just doesn't work. I get the same error no matter what values I try here... This shouldn't be such a difficult issue, how can I solve it?
Code:
sbJavaAlert.Append("alert( "" + msg + "" );");
I can't stand appending a concatenated string. Isn't that the purpose of using a stringbuilder? This is another developer's code and I am adding onto another part of it, but I want to change this too. Or should I just let still waters lie, as the saying goes?
I have a string which contains html and text.If any of the text is not encapsulated by html tags then I want to encapsulate it in <P> tags however certain tags for example anchors and bold tags etc would need to remain within the string.
hgfkjvckvg
<h1>vhjvhj</h1>
fhvjvl <a href="">hvlvnlb</a>
cghcghkgkh
[code]...
I am trying to change the connection string for the registration form in VS 2010.
This is because it links to the local database in the App_Data which I need it to link to another database. I have changed the connection string in the webconig file and this works file for other forms I have created but does not allow me to create new users.
I have used the ASP.net 4.0 template when creating this website.
Why I get an error when my time is PM? The MSDN doc says tt works with AM/PM.
Error I get is: String was not recognized as a valid DateTime
Code:
sDeadlineDtTm = "9/3/2011 1:30PM"
Try
dtDeadlineDtTm = DateTime.ParseExact(sDeadlineDtTm, "M/d/yyyy H:mmtt", System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))
[Code] ....
How to create a connection string using Visual Studio 2010?
View 2 RepliesIf I have JSON like this and pass it to the engine I am using to create a PDF file, the word "null" appears on the PDF. This isn't really my example, but I googled "json replace null empty string" and this was a hit, which is a good representation of my data, also:
{
"relationship": {
"type": "relationship",
"id": null,
"followed_id": null
}
}
We use a rendering engine that creates a PDF from a fixed template and variable data in the form of a json string. But our customers don't want to read that the id is "null", they want to read that the id is blank. In my C# program, the json is just a string, so I can easily do something like this:
jsonString = jsonString.Replace("null,", ",");but the issue is I can't replace null-comma with a comma, because then it's invalid json.
how to I make the rendering engine *and* my customer both happy?
I have a gridview that was displaying and handling postbacks correctly, that is, until I upgraded to .net 4.0 (vs 2010) from .net 3.5. Now I am getting the classic (and in this context meaningless) "Input string was not in a correct format" error upon postback. The postback is initiated by a command button and the row command event handles everything nicely.
The trace shows internal grid postback handling and nothing else:
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +9594283
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
System.Convert.ToInt32(String value, IFormatProvider provider) +48
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1047....
From experience, I know this happens on late binding with wrong type casting on the ASPX side of things. However, nothing has changed. The code is the same, the only thing that changed is the upgrade to 4.0.
I have tried everything I (and a coleague) can think of to figure out what the issue is without luck. No error is raised on the code behind in any method. The only error raised is the Page_Error event and the error object contains the same crap you see in the yellow screen dump (above).
UPDATE: I narrowed the issue down to the RaisePostBackEvent method. I had to reflect the System.Web (for educational purposes of course :) assembly to figure out the code executing after my RowCommand logic(which is fine) breaks. This happens in the HandleEvent method. It checks for known command names (e.g. Select) and if it can't find a match, it defaults to the following:
[Code]....
Is this a bug or am I doing something wrong? The row object is NULL which is why it defaults to the cast. The cast assumes the argument to be an integer however and in my case I am passing a string as an argument?
I have an ASP.net application which returns a binary PDF file (stored from the database, which was previously uploaded) to the client.
The code I have works fine for all browsers, except for internet explorer 6 (story of my life!). In IE6, when a user clicks open, Adobe reports the error: "There was an error opening this document. The file cannot be found."
When the user clicks save, the PDF saves fine and can be opened by double clicking it. I am stumped. Google has given suggestions of caching (setting cachecontrol to private etc) and I have tried all of those but nothing has worked.
The wierd(er) behaviour is when I generate a PDF in my ASP .net server layer (using NFop) from scratch, IE will open it fine (using the SAME code!).
Here is my code for sending the binary data across the wire:
[code]....
I try to get images which you can find in the Attachment of an EmailMessage. But when I run the code I'm getting this error: Object reference not set to an instance of an object.
This is the code:
string sHTMLCOntent = item.Body;
FileAttachment[] attachments = null;
if (item.Attachments.Count != 0)
{
[Code]....
Email is working when form is submitted, but the attachment is not being sent with it.. what im i doing wrong with the logic below: Also, would it be possible to add an attachment without uploading it to the server first?
[Code]....
Can anyone sort out the following code to make the adding an attachment to an email work.
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="ISO-8859-1" Debug="true" %>
<% @Import Namespace="System.Web.Mail" %>
<% @Import Namespace="IO" %>
<script language="vb" runat="server">
[Code].....
[Code]....
send a mail with an attachment in asp.net
Im sending a mail using cdo object. Im hosting the site. Now i want to attach a file which is in the folder adc on the server. Im getting the path of the file from the database eg. abc est.txt. I have written the code for the same but the file is not getting attached properly. If I hardcode the path and test it in visual studio then its working fine.
[Code]....
My current application send an .rtf in an attachement. I wish to send pdf instead of that.Where in my code I should modify the same?
Below is my code
RichTextBox rtbReport = new RichTextBox(); //Creating instance of Richtextbox
AppResult objResult = null; //Object of Class
frmExaminationReport objReport = new frmExaminationReport(examinationID, ProviderID, PatientID, examType); // Object of Class
AddressBookDataTable dtAddress = null;
rtbReport.Rtf = objReport.RTF; // Entire Result is assigned to Richtext box class
frmMail objMail = new frmMail(); //Object of Mail Class
string directoryPath = Application.StartupPath + "\Temp"; //Creating directory
string tempFileName = "Report_" + DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString() + ".rtf"; //Generating Name
FileStream fsReport = new FileStream(directoryPath + "\" + tempFileName, FileMode.CreateNew); // FileStream
fsReport.Write(ASCIIEncoding.ASCII.GetBytes(rtbReport.Rtf), 0, rtbReport.Rtf.Length); // Writing
fsReport.Flush();
fsReport.Close();
fsReport.Dispose();
objMail.MailSubject = examType + " Report"; //Mail Subject
Let me know if any inputs needed