12.3.12

Using Outlook via VB.NET

Hi Everybody,
I would like to explain one of faq within this essay , how we can
use Outlook functions  
via VB.NET Windows Application. 
I am going to explain it with VB.NET 2010.


If any question, please feel free to contact me y_turkeli@yahoo.com or
yenerturkeli@v-basic.net.


1-) We are creating a new Windows Application Project


2-) We are designing this windows form in a similar way to the picture below


3-) We are writing this code

Imports Microsoft.Office.Interop.Outlook
Public Class Form1

   
    Private Sub send_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles send_btn.Click
        Dim my_outlook As New Microsoft.Office.Interop.Outlook.Application()
        Dim my_namespace As Microsoft.Office.Interop.Outlook.NameSpace
        Dim my_folder As Microsoft.Office.Interop.Outlook.MAPIFolder


        my_namespace = my_outlook.GetNamespace("MAPI")
        my_namespace.Logon()

        Dim my_mail As Microsoft.Office.Interop.Outlook.MailItem

       

        my_folder = my_namespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox)

        my_mail = my_folder.Items.Add(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)

        my_mail.Attachments.Add("c:\db1.mdb")
        my_mail.Subject = "From Outlook"
        my_mail.Body = text_txt.Text
        my_mail.To = to_txt.Text
        my_mail.CC = cc_txt.Text


        my_mail.Send()
    End Sub
End Class

4-) Lets run the application



4-) Please allow your program to send email


5-) Check your email box 


Have a nice day
Yener Turkeli

8.3.12

Encrypt Connectionstring on Webconfig File



Hi Everybody,
I would like to explain one of faq within this essay , how we can 
Encrypt connectionstring 

via ASP.NET on webconfig file. I am going to explain it with VB.NET 2010.


If any question, please feel free to contact me y_turkeli@yahoo.com or
yenerturkeli@v-basic.net.


1-) We are creating a new Windows Application Project


2-) We are designing this windows form in a similar way to the picture below


Web Config 

<?xml version="1.0"?>

<configuration>
<appSettings/>
  <connectionStrings>
    <add name="my_con" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|test.mdf;User Instance=true"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
<system.web>
<compilation debug="true">
</compilation>
<authentication mode="Windows"/>
</system.web>
</configuration>





3-) We are writing this code

Imports System.Web.Configuration
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Encrypt_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Encrypt_btn.Click

        Dim file As Configuration = _
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

        Dim confg As ConfigurationSection = file.GetSection("connectionStrings")

        confg.SectionInformation.ProtectSection("")

        file.Save()
    End Sub

    Protected Sub read_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles read_btn.Click
        con_lbl.Text = ConfigurationManager.ConnectionStrings("my_con").ConnectionString
    End Sub

    Protected Sub Decrypt_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Decrypt_btn.Click

        Dim file As Configuration = _
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

        Dim confg As ConfigurationSection = file.GetSection("connectionStrings")

        confg.SectionInformation.UnprotectSection()

        file.Save()

    End Sub
End Class

4-) Lets run the application



Encrypted 

<?xml version="1.0"?>

<configuration>
<appSettings/>
  <connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
    <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
      xmlns="http://www.w3.org/2001/04/xmlenc#">
      <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
          <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
          <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
            <KeyName>Rsa Key</KeyName>
          </KeyInfo>
          <CipherData>
            <CipherValue>ZBGdEa6zhAmdVQlvHJ2eFmYHD2w3Hl4pDg22JZUUphaNpQYXv0D88ppkinpW8yleZXA2Pws8N5BWyhESfLaYF+dZRas0omjEtxT0nl9/mcRgBXyZYbgsbvAh0g+bIbDYEAsMbHDOXdWfXqPoBTqoqA8lRvzmRXT/cD5kVpZvQys=</CipherValue>
          </CipherData>
        </EncryptedKey>
      </KeyInfo>
      <CipherData>
        <CipherValue>PXsYuKxLKONkZeMdd9NKyUSC6gYsCOmWcPyUrhIuah7FIPLdDO7erNpANt1Si+aInPXMS9MmdfUmCGawlAeZ5zAv7C9yxeUcugI/56alKqHzTBZIOcuYHcZ6z6wVg9iXCHU8S7L/WQqNfY6DVfkeHZnhWnt6v9nki/pkboDzNFyntpgXqD+RHB+/YOJm7MRSBmMQ8uJ5HaTL035pIq4xPhMBuBFk1t2WesBpLOlDAIdy8lQPMcpuyF9MWRyuEYUJUSnwTx3FoPEIPNiu2DfEGSIl1NX2FGd231BrumtiqOhiGynw4qM6dBcWkA9maLR+29Adj86Gc64=</CipherValue>
      </CipherData>
    </EncryptedData>
  </connectionStrings>
<system.web>
<compilation debug="true">
</compilation>
<authentication mode="Windows"/>
</system.web>
</configuration>




5-) Read Connectionstring 



Decrypted Web Config 

<?xml version="1.0"?>

<configuration>
<appSettings/>
  <connectionStrings>
    <add name="my_con" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|test.mdf;User Instance=true"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
<system.web>
<compilation debug="true">
</compilation>
<authentication mode="Windows"/>
</system.web>
</configuration>




Have a great day
Yener Turkeli 

6.3.12

Hand Writing with VB.NET 2010

Hi Everybody,
I would like to explain one of faq within this essay , how we can hand writing via VB.NET. I am going to explain it with VB.NET 2010.


If any question, please feel free to contact me y_turkeli@yahoo.com or
yenerturkeli@v-basic.net.


1-) We are creating a new Windows Application Project 


2-) We are designing this windows form in a similar way to the picture below


3-) We are writing this code


Public Class Form1

    Dim my_picture As New System.Drawing.Drawing2D.GraphicsPath()
    Dim my_color As New Color()
   


    Private Sub PictureBox1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles my_board.Paint


        Dim draw_ = New Pen(my_color, pen_txt.Text)

        e.Graphics.DrawPath(draw_, my_picture)

       
    End Sub








    Private Sub my_board_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles my_board.MouseMove
        If e.Button = MouseButtons.Left Then

            my_picture.AddLine(e.X, e.Y, e.X, e.Y)

        End If


        my_board.Invalidate()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        my_color = Color.Blue
    End Sub

    Private Sub my_board_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles my_board.MouseUp
        my_picture.StartFigure()
    End Sub

    Private Sub pen_color_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pen_color.Click
        Dim my_dia As New ColorDialog
        my_dia.ShowDialog()
        my_color = my_dia.Color
    End Sub

    Private Sub picture_color_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picture_color.Click
        Dim my_dia As New ColorDialog
        my_dia.ShowDialog()
        my_board.BackColor = my_dia.Color
    End Sub
End Class



4-) Lets run the application



5-) Lets change background color and foreground color 


6-) Lets write something 




Have a nice day
Yener Turkeli
yenerturkeli@v-basic.net 




Nominate an MVP

Nominate an MVP


Hi All,
If anybody want to nominate me for MVP Award 2012, please send an email to

mvpga@microsoft.com. Here you can outline how your nominee voluntarily and actively participates in online and/or offline community activities that focus on Microsoft technologies.

  • Nominee’s name ( Yener Turkeli)
  • Nominee’s e-mail address ( yenerturkeli@v-basic.net)
  • Country where the nominee lives ( Australia)
  • Nominee’s main spoken language (English-Turkish)
  • One or two Microsoft technologies or products that are the nominee’s area of expertise (for example, Microsoft V-Basic.NET , ASP.NET )
  • Specific examples of online/offline community activities in which the person you are nominating participates ( www.v-basic.net , Visual Basic Egitmenim (book))

Successful candidates will be contacted by a member of the Microsoft MVP Award Program team.

Thank you for your interest!

http://mvp.support.microsoft.com/gp/mvpnominate 

Have a nice day
Yener Turkeli