1
Answer

I cant see where I am going wrong ?

Haider Kubba

Haider Kubba

16y
2k
1
Hi guys this is my first post on here now I dont want the answer I just want a hint as to where I am going wrong

my code is:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;

namespace PrintMyName
{
    class GetName
    {
        private string Surname;                                                    

        public void whatsthename()
        {
            Console.Write("Please Enter your name: ");
            surname = (Console.ReadLine());
        }
                                                                                   
        public string surname       
        {
            set
            {
                Surname = value;
            }
            get
            {
                return Surname;
            }
        }
    }

        public delegate void Printingname();

        public class nameprinting
        {
            public void FireMyFire() //the firing method
            {
                GetName gn = new GetName();
                gn.whatsthename();
            }

            public void MyPrintMethod(object sender, PrintPageEventArgs args)
            {
                GetName gn = new GetName();
                nameprinting np = new nameprinting();
                Graphics gr = args.Graphics;
                String drawString = gn.surname;
                Font drawFont = new Font("Arial", 16);
                SolidBrush drawBrush = new SolidBrush(Color.Black);
                PointF drawPoint = new PointF(500.0F, 500.0F);
                gr.DrawString(drawString, drawFont, drawBrush, drawPoint);
            }


        }

        class MainClass
        {
            public static void Main(string[] args)
            {
                //GetName gn = new GetName();
                nameprinting np = new nameprinting();
                MainClass mc = new MainClass();
                PrintDocument pd = new PrintDocument();
                np.FireMyFire();
                pd.PrintPage += new PrintPageEventHandler(np.MyPrintMethod);
                pd.Print();
                Console.ReadLine();
            }
        }
    }

I take a name and then print it on a page but I am getting a null value when I go to the MyPrintMethod method I just dont know why?????

ps. I have only been using C# for like 3 months so take it easy on me.

thanks.
Answers (1)
0
Bechir Bejaoui
NA 20.1k 5.3m 16y

In this case you have to implement security logic, the .Net provides an entire API  System.Security, you can create a permission set that determines rule of messages transactions 
0
Riccardo
NA 5 0 16y
I mean every outgoing mail of a company (mail from a internal network to outside the network)
0
Bechir Bejaoui
NA 20.1k 5.3m 16y

What do you mean by outgoing mail, do you mean from example a spam?
0
Riccardo
NA 5 0 16y
Thank you very much for your answer!

Probably I should explain a little bit more about the functionality I would like to implement. Basicaly I would like to check every outgoing mail. Therefore I would like to
1. stop the smtp queue
2. wait for messages
3.check these messages (allowed or unallowed and probably remove some of them)
4. Start the smtp queue, so the messages can be send


0
Bechir Bejaoui
NA 20.1k 5.3m 16y

If I well understand your question you're using a Message queue object then you can do

MessageQueue mqueue = new MessageQueue();
            //This method will make the message queue in a standby state for any message
            IAsyncResult Async = mqueue.BeginReceive();

            //TO do perform you code here

            //This method
            Message Recived = mqueue.EndReceive(Async);
           
            //close the message queue
            mqueue.Close();
It's better to do that asynchormously