473,811 Members | 3,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create Outlook Distribution List using VB.net?

9 New Member
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 2061

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

Similar topics

0
1433
by: egelendu | last post by:
How to create email distribution list in yahoo mail?
0
1487
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 create a distribution list from it. Right now I store the addresses twice, first in the mysql-table, and second in mailman. I would like to circumvent the second. Anyone knows how to do this?
4
17127
by: michiel | last post by:
Does anybody know how to create a email distrubution list in ms Access thanks
1
2123
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
2597
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 the db. How do I set up an Outlook distibution list that basically runs a pre-defined Access query to retrieve the most current email addresses any time that particular distribution list is used? I'm either not understanding most of the help...
5
11899
by: Imry | last post by:
Is there a way to programatically add items to the outlook task list using VB ..net?
1
2111
by: Oren nizri | last post by:
i need to create new microsoft outlook mail profile by using visual basic...
0
1743
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 be creating. There is a distribution list item object, but no dsitribution list object to contain the items!
5
4554
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 adresses like istea@yahoo.com.au. Does anybody has an idea? Many thanks in advance.
0
1113
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?
1
10395
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10130
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9204
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7667
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5553
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.