473,396 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to create Outlook Distribution List using VB.net?

For days now I've been trying to create a Distribution List in Outlook from my VB.net app. I can create one but I cannot put any members in it because there seems to be no way to define and create a recipient. This used to work in older versions of VB but now Microsoft seems to have changed something.

Here is my code:

Expand|Select|Wrap|Line Numbers
  1.         ' Start Outlook.
  2.         ' If it is already running, you'll use the same instance...
  3.         Dim olApp As Microsoft.Office.Interop.Outlook.Application
  4.         olApp = CreateObject("Outlook.Application")
  5.  
  6.         ' Logon. Doesn't hurt if you are already running and logged on...
  7.         Dim olNs As Microsoft.Office.Interop.Outlook.NameSpace
  8.         olNs = olApp.GetNamespace("MAPI")
  9.         olNs.Logon()
  10.  
  11.         ' Create and Open a new contact.
  12.         Dim olItem As Microsoft.Office.Interop.Outlook.ContactItem
  13.         olItem = olApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olContactItem)
  14.  
  15.         ' Create a new Distribution List
  16.         Dim myDistList As Microsoft.Office.Interop.Outlook.DistListItem
  17.         myDistList = olApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olDistributionListItem)
  18.  
  19.         ' Create a new MailItem
  20.         Dim myMailItem As Microsoft.Office.Interop.Outlook.MailItem
  21.         myMailItem = olApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
  22.  
  23.         Dim myRecip As Microsoft.Office.Interop.Outlook.Recipient
  24.         myRecip = olApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.recipient)
  25. ' this line above fails saying recipient is not a member of microsoft.office.interop.outlook.olitemtype
  26.  
  27.         myDistList.DLName = "Test List"
  28.         myDistList.AddMember(myRecip)
  29.         myDistList.Save()
  30.  
  31.         olApp = Nothing
  32.         olNs.Logoff()
  33.         olNs = Nothing
  34.         olItem = Nothing
  35.         myDistList = Nothing
  36.         myMailItem = Nothing
Feb 4 '11 #1
0 2029

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: egelendu | last post by:
How to create email distribution list in yahoo mail?
0
by: Sjoerd Mulder | last post by:
Hi all, I'm currently managing a site with information from our members such as phonenumbers and emailaddresses, stored in a table. I would like to retrieve the emailaddresses from the table and...
4
by: michiel | last post by:
Does anybody know how to create a email distrubution list in ms Access thanks
1
by: Dave | last post by:
Using Outlook2k on Win2k/XP, is there a way to produce the addresses that make up an Outlook Distribution List?
1
by: M Stery | last post by:
I'm confused about the best way to accomplish this. Master Access db holds email addresses for a variety of job titles. Personnel holding those job titles and email addresses change all the time in...
5
by: Imry | last post by:
Is there a way to programatically add items to the outlook task list using VB ..net?
1
by: Oren nizri | last post by:
i need to create new microsoft outlook mail profile by using visual basic...
0
by: Jason James | last post by:
Hi all, does anyone have any suggestions as to the steps involved in creating a DL using VB.Net. I have some Outlook automation experience but I'm not sure what the objects are that I should...
5
by: isetea | last post by:
Hi, I have a module, which contains a SendEmail Function. In the MailSendItem I want to enter an Outlook Distribution List as the ".To". But it's not going to work. I can only enter complete email...
0
by: =?Utf-8?B?Z29vZDR3b3Jr?= | last post by:
Is it possible to program in VB.Net that retrieve a distribution list from active directory and then add or remove people in the distribution list?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.