<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Technical - Messaging</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/sachinsancheti/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/sachinsancheti/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:09:30 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Calling Outlook VBA Macro from outside (VB/VBScript/C#)</title>
      <link>https://docs.microsoft.com/archive/blogs/sachinsancheti/calling-outlook-vba-macro-from-outside-vbvbscriptc</link>
      <pubDate>Tue, 16 May 2006 10:38:00 GMT</pubDate>
      <dc:creator><![CDATA[sachinsa]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sachinsancheti/2006/05/16/calling-outlook-vba-macro-from-outside-vbvbscriptc/</guid>
      <description><![CDATA[It&nbsp;seems to be insignificant but it&nbsp;might turn&nbsp;out to be&nbsp;useful some...]]></description>
      <content:encoded><![CDATA[<FONT face=Arial>
<P><SPAN style="FONT-FAMILY: Arial">It&nbsp;seems to be insignificant</SPAN><FONT face="Times New Roman"> </FONT><SPAN style="FONT-FAMILY: Arial">but it&nbsp;might turn&nbsp;out to be&nbsp;useful some times.<BR>Consider a situation where you have a VBA Macro in outlook (any office application for that matter) the name of the subroutine is SendCustomEmail and you want it to call from outside the outlook (it should be running or you can make it run).<BR><BR>The <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:PersonName w:st="on">sam</st1:PersonName>ple code to call SendCustomEmail&nbsp;here is in vbscript.<BR><BR></SPAN><STRONG><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">set app= createobject("Outlook.Application")</SPAN></STRONG><B><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><BR><STRONG><SPAN style="FONT-FAMILY: Arial">call app.SendCustomEmail("</SPAN></STRONG></SPAN></B><SPAN style="FONT-FAMILY: Arial"><A href="mailto:test@mydomain.com"><STRONG><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">test@mydomain.com</SPAN></STRONG></A></SPAN><STRONG><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">")</SPAN></STRONG><SPAN style="FONT-FAMILY: Arial"><BR><BR>You will have to write subroutine SendCustomEmail with a parameter in outlook macro.<BR><BR>It is easy in VBScript or VB for that matter as we can directly make use of the late binding.<BR><BR>In case of .Net here in C#<BR><BR>&lt;CODE BLOCK&gt;</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P><STRONG><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Type mtype;</SPAN></STRONG><B><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><BR><STRONG><SPAN style="FONT-FAMILY: Arial">Microsoft.Office.Interop.Outlook.Application outlook;</SPAN></STRONG><BR><STRONG><SPAN style="FONT-FAMILY: Arial">outlook = <SPAN style="COLOR: blue">new</SPAN> Microsoft.Office.Interop.Outlook.ApplicationClass(); </SPAN></STRONG><BR><STRONG><SPAN style="FONT-FAMILY: Arial">mtype = outlook.GetType(); </SPAN></STRONG><BR><STRONG><SPAN style="COLOR: blue; FONT-FAMILY: Arial">string</SPAN></STRONG><STRONG><SPAN style="FONT-FAMILY: Arial">[] strArr;</SPAN></STRONG><BR><STRONG><SPAN style="FONT-FAMILY: Arial">strArr = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: blue">string</SPAN>[1];</SPAN></STRONG><BR><STRONG><SPAN style="FONT-FAMILY: Arial">strArr[0] = "</SPAN></STRONG></SPAN></B><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><A href="mailto:test@mydomain.com"><STRONG><SPAN style="FONT-FAMILY: Arial">test@mydomain.com</SPAN></STRONG></A><STRONG><SPAN style="FONT-FAMILY: Arial">";</SPAN></STRONG><B><BR><STRONG><SPAN style="FONT-FAMILY: Arial">mtype.InvokeMember("SendCustomEmail",System.Reflection.BindingFlags.InvokeMethod,<SPAN style="COLOR: blue">null</SPAN>,outlook,strArr); </SPAN></STRONG></B><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-FAMILY: Arial">&lt;/CODE BLOCK&gt;<BR><BR>Similarly we can also call Macro written in word, excel etc. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-FAMILY: Arial">Hope this turn up to be useful some where.<BR><BR>-<st1:PersonName w:st="on"><st1:PersonName w:st="on">Sachin</st1:PersonName> Sancheti</st1:PersonName><BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">An obstacle is what we see when we take our eyes off the goal.</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> <o:p></o:p></SPAN></P>
<P>&nbsp;</P></FONT>]]></content:encoded>
    </item>
    <item>
      <title>How to Delete recurring appointments using CDO</title>
      <link>https://docs.microsoft.com/archive/blogs/sachinsancheti/how-to-delete-recurring-appointments-using-cdo</link>
      <pubDate>Mon, 15 May 2006 14:04:00 GMT</pubDate>
      <dc:creator><![CDATA[sachinsa]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sachinsancheti/2006/05/15/how-to-delete-recurring-appointments-using-cdo/</guid>
      <description><![CDATA[Hi, I work with Microsoft PSS Messaging Team. Thought of sharing few things which I learned in my...]]></description>
      <content:encoded><![CDATA[<P><FONT face=Arial>Hi, I work with Microsoft PSS Messaging Team. Thought of sharing few things which I learned in my troubleshooting. This is one of them!! <BR><BR>How to Delete recurring appointments using CDO.<BR>Code to delete appointment is generally follwed like this:<BR><BR><FONT size=1>For Each oMsg in oMsgCol<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iCount = iCount + 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Instr(oMsg.Sender.Name, "/OU") &gt; 0 Then 'Checking if the email address is no more in use. Generally used for&nbsp; </FONT></FONT><FONT face=Arial><FONT size=1><BR>people&nbsp;&nbsp; who left the organization and email account is being deleted.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Wscript.Echo iCount &amp; " - " &amp; oMsg.StartTime &amp; ";" &amp; oMsg.EndTime &amp; ";" &amp; oMsg.Organizer &amp; ";" &amp; oMsg.Subject <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oMsg.Delete<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iDeleted = iDeleted + 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>Next<BR><BR><FONT size=3>Above code block would fail in case of recurring appointments. Because recurring appointments are linked with master appointment and correct way for deleting recurring appointment would be through master appointment.<BR><BR>A code block would look like below<BR><BR><FONT size=1></P>
<P>If oMsg.IsRecurring Then<BR>&nbsp;&nbsp; Set MasterAppt = oMsg.GetRecurrencePattern.Parent 'Get the parent Appointment<BR>&nbsp;&nbsp;&nbsp;MasterAppt.ClearRecurrencePattern<BR>&nbsp;&nbsp; MasterAppt.Update<BR>&nbsp;&nbsp; MasterAppt.Delete<BR>End If<BR>Set MasterAppt = Nothing 'Set the master appointment to nothing<BR>'Cleanup<BR>oMsg.Delete<BR>Set oMsg = Nothing</P>
<P><FONT size=3>Looking at the code above we could see that we need to actually clear the recurrence pattern first before deleting the recurring appointment. IsRecurring property returns whether the appointment is recurring or not.<BR><BR>A complete code block would look like below:<BR><BR><FONT size=1></P>
<P>For Each oMsg in oMsgCol<BR>&nbsp;&nbsp; iCount = iCount + 1<BR>&nbsp;&nbsp; If Instr(oMsg.Sender.Name, "/OU") &gt; 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Wscript.Echo iCount &amp; " - " &amp; oMsg.StartTime &amp; ";" &amp; oMsg.EndTime &amp; ";" &amp; oMsg.Organizer &amp; ";" &amp; oMsg.Subject <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If oMsg.IsRecurring Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set MasterAppt = oMsg.GetRecurrencePattern.Parent 'Get the parent Appointment<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MasterAppt.ClearRecurrencePattern<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MasterAppt.Update<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MasterAppt.Delete<BR>&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp; Set MasterAppt = Nothing 'Set the master appointment to nothing<BR>&nbsp;&nbsp; oMsg.Delete<BR>&nbsp;&nbsp; iDeleted = iDeleted + 1<BR>&nbsp;&nbsp; set oMsg=Nothing<BR>&nbsp;&nbsp; set MasterAppt = Nothing<BR>End If<BR>Next<BR><BR><FONT size=3>- Hope this helps somebody somewhere!!<BR><BR>-Sachin Sancheti<BR></FONT><FONT size=2><STRONG>you are never given a wish without giving power to fulfill it.!!!</STRONG></FONT></P></FONT></FONT></FONT></FONT></FONT></FONT>]]></content:encoded>
    </item>
  </channel>
</rss>