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
S

sdesilets

@sdesilets
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Send message to Microsoft teams group via connector
    S sdesilets

    Thank you so much for your answer..

    lmoelleb wrote:

    The first suspicious thing I see is you call an async method SendMsgAsync() without waiting for it. This means your Main method can execute the code following myprog.sendMsg() before the message is put on the network.

    You was right, I was able to make it run by putting a Thread.Sleep(5000) after myprog.sendMsg(),is not optimal but it work for now.

    lmoelleb wrote:

    You should make your Main async as well and await the async calls - then it will not terminate before completion (and you will also see any errors). You might also when googling find advise to call .Result or .Wait. Those are excellent advise for people who like to debug why there software occasionally hangs after they make a completely unrelated change. Sure you can use them if you know how it really works under the hood - but that is not a good topic for a beginner.

    I gonna check this. Thank you so much for your help!

    C# csharp sharepoint linq graphics collaboration

  • Send message to Microsoft teams group via connector
    S sdesilets

    Hello everybody, I pretty new to programming, what I want to do is a C# program that will send a message to a Microsoft teams group via a webhook connector of this group. I was able to achieve it with a Desktop code(with form),but I need it to be a console program, I have pretty much copy/paste the code from my Desktop project to my console project, but there something that don't work. Here is my code from my desktop project:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Net.Http;
    using System.Net.Http.Headers;
    using System.Text;
    using System.Text.Json;

    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace test_team_2
    {
    public partial class Form1 : Form
    {
    string[] cmdLineMe = Environment.GetCommandLineArgs();
    string webhookPdfTermine = "uri to my team groups;
    HttpClient client = new HttpClient();
    Message body = new Message();
    string finalMessage = "";

        public Form1()
        {
            InitializeComponent();
        }
    
        private void Form1\_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < cmdLineMe.Length; i++)
            {
                finalMessage = cmdLineMe\[i\];
            }
    
            sendMsg();
    
        }
    
        public class Message
        {
            public string text { get; set; }
        }
    
        private async Task SendMsgAsync()
        {
    
            MessageBox.Show(finalMessage);
            client.BaseAddress = new Uri(webhookPdfTermine);
            body.text = finalMessage;
            string serializeJson = JsonSerializer.Serialize(body);
            StringContent content = new StringContent(serializeJson, Encoding.UTF8, "application/json");
            \_ = await client.PostAsync(client.BaseAddress, content);
        }
    
        void sendMsg()
        {
            
            \_ = SendMsgAsync();
    
        }
    
    }
    

    }

    And here is my code for my console project:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Net.Http;
    using System.Net.Http.Headers;
    using System.Text.Json;

    namespace TeamBots
    {
    class Program
    {
    string[] cmdLineMe = Environment.GetCommandLineArgs();
    string webhookPdfTermine = "uri to my team groups";
    HttpClient client = n

    C# csharp sharepoint linq graphics collaboration
  • Login

  • Don't have an account? Register

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