Autor Beitrag
estrella1410
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Mo 10.12.07 13:47 
hallöle

also ich habe mal meinen code hier reingepackt...das problem liegt in der variablen "body" da komm ich nicht weiter!

ich kriege es nicht hin dass der den inhalt der lstbox so übernimmt wie er is also MIT leerzeilen sondern er hängt alles aneinander ...das is mein problem ..ich weis aba nicht wie ich "enter" einbauen soll...habe nun einiges versucht..über ASCII 10, 13 bis hinzu \u2305 wie unten steht....

kann mir wer helfen??

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using email.Properties;
using System.Net.Mail;
using System.Net.Mime;

namespace email
{
    public partial class Form1 : Form
    {
        string name, dummy, dummy2, emailinhalt;


        public Form1()
        {


            InitializeComponent();

        }
        private void btnAnhang_Click(object sender, EventArgs e)
        {
            //nur PDF anzeigen; PDF Datei auswählen;
            name = Settings.Default.name;
            StreamReader sr_log = new StreamReader(name);


            dummy = sr_log.ReadLine();
            txtbcc.Text = (dummy + ";");


            openFile.Filter = "nurPDF|*.pdf";

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                lblanhang.Text = ("Folgende Datei wurde angehängt: " + openFile.FileName);
                lblanhang.Visible = true;
            }
        }

        private void btnSenden_Click_1(object sender, EventArgs e)
        {

            emailinhalt = Settings.Default.emailinhalt;
            
            StreamReader sr_log2 = new StreamReader(emailinhalt);
            string subject = txtbetreff.Text;
            string body = dummy2 ;

//            char[] crlf = { (char)13, (char)(10) };



            do
            {
                dummy2 = sr_log2.ReadLine();

                //if (dummy2 == "")
                //{
                //    dummy2 = Environment.NewLine;
                //}
                lstBody.Items.Add(dummy2);
                body = body + (dummy2 +(char)'\u2305');
            }
            while (sr_log2.EndOfStream == false);

                MailMessage dieMail = new MailMessage("abc@def.de", dummy, subject, body);
                body = dieMail.Body;       

                dieMail.Attachments.Add(new Attachment(openFile.FileName.ToString()));
                //dieMail.IsBodyHtml =true;
                //string someArrows = new string(new char[] { '\u2190', '\u2191', '\u2192' ,'\u2305'});
                //dieMail.Body += Environment.NewLine + someArrows;
                //dieMail.BodyEncoding = System.Text.Encoding.UTF8;

                SmtpClient Server = new SmtpClient("abc.def.loc");
                Server.Send(dieMail);

        }
    }
}


Moderiert von user profile iconChristian S.: Code- durch C#-Tags ersetzt
golgol
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 58

Win XP Prof. / Linux
C# (VS 2005)
BeitragVerfasst: Mo 10.12.07 13:55 
Ganz allgemein funktioniert das so (str1 und str2 sind bereits initialisiert und deklariert):

ausblenden C#-Quelltext
1:
String sText = str1 + "\r\n" + str2;					


Bei e-Mails müsste es eigentlich reichen, wenn du das "\n" benutzt.
estrella1410 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Mo 10.12.07 14:00 
ohjeeee....na soe infach hab ich nicht gedacht ...mit "\r\n" hatte ichs auchversucht aber das klappte nicht!

Vielen Dank, "\n" klappt!

Gruß,

Jessy