Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. I am trying to send an automated email from the company's exchange server, but it doesn't recognize the "ExchangeService " and "EmailMessage" in the following C# code

I am trying to send an automated email from the company's exchange server, but it doesn't recognize the "ExchangeService " and "EmailMessage" in the following C# code

Scheduled Pinned Locked Moved C#
helpcsharpcomsysadmin
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 10307097
    wrote on last edited by
    #1

    This is my code. Please help. string from = "myemail@myexchangeserver.com"; string to = "recipient@email.com"; ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);//error here service.AutodiscoverUrl(from); EmailMessage message = new EmailMessage(service);// Error here message.Subject = "Email Subject"; message.Body = richTextBox1.Text; message.ToRecipients.Add(to); message.Save(); message.SendAndSaveCopy();

    L Richard DeemingR 2 Replies Last reply
    0
    • U User 10307097

      This is my code. Please help. string from = "myemail@myexchangeserver.com"; string to = "recipient@email.com"; ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);//error here service.AutodiscoverUrl(from); EmailMessage message = new EmailMessage(service);// Error here message.Subject = "Email Subject"; message.Body = richTextBox1.Text; message.ToRecipients.Add(to); message.Save(); message.SendAndSaveCopy();

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      What error messages do you receive?

      Veni, vidi, abiit domum

      U 1 Reply Last reply
      0
      • L Lost User

        What error messages do you receive?

        Veni, vidi, abiit domum

        U Offline
        U Offline
        User 10307097
        wrote on last edited by
        #3

        the error says "you might be missing a using directive".

        M L 2 Replies Last reply
        0
        • U User 10307097

          the error says "you might be missing a using directive".

          M Offline
          M Offline
          Marco Bertschi
          wrote on last edited by
          #4

          What is a using-directive[^]

          Veni, vidi, caecus

          1 Reply Last reply
          0
          • U User 10307097

            the error says "you might be missing a using directive".

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Are you saying you have not included #using directives for all the classes you are trying to use? This is a fundamental part of .NET, which every developer needs to understand.

            Veni, vidi, abiit domum

            1 Reply Last reply
            0
            • U User 10307097

              This is my code. Please help. string from = "myemail@myexchangeserver.com"; string to = "recipient@email.com"; ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);//error here service.AutodiscoverUrl(from); EmailMessage message = new EmailMessage(service);// Error here message.Subject = "Email Subject"; message.Body = richTextBox1.Text; message.ToRecipients.Add(to); message.Save(); message.SendAndSaveCopy();

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              Make sure you have a reference to the Microsoft.Exchange.WebServices assembly, and a using Microsoft.Exchange.WebServices.Data; statement at the top of your code file.


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups