.......

footix97.egloos.com

포토로그 마이가든



Picturebox 이미지 축소~! DEV-C#

private static Image resizeImage(Image imgToResize, Size size)
{
   int sourceWidth = imgToResize.Width;
   int sourceHeight = imgToResize.Height;

   float nPercent = 0;
   float nPercentW = 0;
   float nPercentH = 0;

   nPercentW = ((float)size.Width / (float)sourceWidth);
   nPercentH = ((float)size.Height / (float)sourceHeight);

   if (nPercentH < nPercentW)
      nPercent = nPercentH;
   else
      nPercent = nPercentW;

   int destWidth = (int)(sourceWidth * nPercent);
   int destHeight = (int)(sourceHeight * nPercent);

   Bitmap b = new Bitmap(destWidth, destHeight);
   Graphics g = Graphics.FromImage((Image)b);
   g.InterpolationMode = InterpolationMode.HighQualityBicubic;

   g.DrawImage(imgToResize, 0, 0, destWidth, destHeight);
   g.Dispose();

   return (Image)b;
}

ews를 이용한 메일 보내기 Exchange&AD&OCS

static void CreateEmail()
{
    // Create service binding.
    ExchangeServiceBinding esb = new ExchangeServiceBinding();
    esb.Credentials = new NetworkCredential("username", "password", "domain");
    esb.Url = @"https://CAS01.example.com/EWS/exchange.asmx";

    // Create the CreateItem request.
    CreateItemType createItemRequest = new CreateItemType();

    // Specifiy how the created items are handled
    createItemRequest.MessageDisposition = MessageDispositionType.SendAndSaveCopy;
    createItemRequest.MessageDispositionSpecified = true;

    // Specify the location of sent items.
    createItemRequest.SavedItemFolderId = new TargetFolderIdType();
    DistinguishedFolderIdType sentitems = new DistinguishedFolderIdType();
    sentitems.Id = DistinguishedFolderIdNameType.sentitems;
    createItemRequest.SavedItemFolderId.Item = sentitems;

    // Create the array of items.
    createItemRequest.Items = new NonEmptyArrayOfAllItemsType();

    // Create a single e-mail message.
    MessageType message = new MessageType();
    message.Subject = "Daily Report";
    message.Body = new BodyType();
    message.Body.BodyType1 = BodyTypeType.Text;
    message.Body.Value = "(1) Handled customer issues, (2) Saved the world.";
    message.ItemClass = "IPM.Note";
    message.Sender = new SingleRecipientType();
    message.Sender.Item = new EmailAddressType();
    message.Sender.Item.EmailAddress = "user1@example.com";
    message.ToRecipients = new EmailAddressType[1];
    message.ToRecipients[0] = new EmailAddressType();
    message.ToRecipients[0].EmailAddress = "user2@example.com";
    message.Sensitivity = SensitivityChoicesType.Normal;

    // Add the message to the array of items to be created.
    createItemRequest.Items.Items = new ItemType[1];
    createItemRequest.Items.Items[0] = message;

    try
    {
        // Send the request to create and send the e-mail item, and get the response.
        CreateItemResponseType createItemResponse = esb.CreateItem(createItemRequest);

        // Determine whether the request was a success.
        if (createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Error)
        {
            throw new Exception(createItemResponse.ResponseMessages.Items[0].MessageText);
        }
        else
        {
            Console.WriteLine("Item was created");
        }

    }
    catch(Exception e)
    {
        Console.WriteLine(e.Message);
    }
}


1 2 3 4 5 6 7 8 9 10 다음