title: VB: Generate E-Mail via outlook
body: <p>Microsoft outlines how to leverage the Microsoft.Office.Interop.Outlook namespace quite well. <a href="https://msdn.microsoft.com/en-us/library/office/bb644320.aspx" rel="nofollow noreferrer">example</a></p>
  
  <p>I currently have a <strong>window form app created in VB,</strong> with a series of text fields requiring input. Upon submission of form, I have a text file that is created locally, but I also want to chain that event with the creation of an email, in a template fashion, having the user values embedded in the body of said email. </p>
  
  <p>In my initial testing, to simply just generate the email, I have imported the appropriate function based on MS's documentation. </p>
  
  <pre><code>Imports Outlook = Microsoft.Office.Interop.Outlook
  </code></pre>
  
  <p>However when I enter the code provided after my text file creation code, there are many errors highlighted. I was prompted to create a <em>friendclass</em> for "Office." </p>
  
  <p>Build does not like the <em>CType(Application.CreateItem(Outlook.OlItemType</em> - I observe the error <em>CreateItem is not a member of Application.</em> </p>
  
  <p>Is this due to the windows form I selected when building this project? </p>
  
  <pre><code>Dim mail As Outlook.MailItem = CType(Application.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem)
  </code></pre>
  
  <p>Any help would be appreciated.. </p>