NeoPa 32,556
Expert Mod 16PB
I am using Outlook Automation (from within Access) to create a MailItem object (an email to you and me). The {MailItem}.recipients.Add() method is often fine for adding an addressee (from the Contacts folder), but I find that I am unable to select the individual SMTP address where the contact has more than one.
If anyone knows how this can be done then I'd be interested to hear.
17 4449 NeoPa 32,556
Expert Mod 16PB
Thanks Nico.
I was already looking at the Recipient object of course, but your link pointed me at a resource that explained it better than what I'd found in the Help system. Obviously I'd Googled, but hadn't found what I needed.
When I have finalised my code (after finalising my understanding of course) I'll post some more info for anyone else to find with similar problems.
Cheers :)
PS. The bit I found that I think most likely to give me what I need is http://msdn.microsoft.com/en-us/libr...EXCHG.10).aspx.
Hey Neo. I am working on a new project and will need to implement an email portion. When you are done can you send me some stuff you did maybe I can use some of it. It will save me a lot of time. I'm not quite ready for that aspect but should be in a couple weeks.
cheers,
NeoPa 32,556
Expert Mod 16PB
Just let me know nearer the time. I will have made more progress then.
You can also let me know (then) exactly what you're looking for.
PS. I should warn you that this code does fall foul of fairly annoying Outlook warnings that non-Outlook software is trying to (1) access addresses and (2) send email on your behalf.
This is something I intend to progress with, but to date I've hit problems.
NeoPa 32,556
Expert Mod 16PB
That looks very interesting Nico - Thanks.
I am most of the way there using the standard Outlook object model, but this one may prove a better solution for me. I will certainly look into it and post back my comments. That may be a bit delayed though, as I am now working on another aspect of this particular project where I have to dig up the correct data that later will be e-mailed or FTPed across to the customer.
I know nothing about CDO at this time, so I will need to read up some. I do know that the firewalls we have here will disallow any SMTP traffic from anywhere but a few well restricted servers (and all the Exchange servers are set not to allow SMTP relaying). Had it not been for that I think I would have been happiest simply knocking an SMTP solution together.
All this because a bunch of personality-less morons decided to use the internet to spread their detritus. Anyway, all good fun.
NeoPa 32,556
Expert Mod 16PB
PS. From my initial research it seems that CDO does use the SMTP protocol exclusively, which puts it out of scope for me I'm afraid.
I will update the thread with any progress I make using Outlook automation.
I will include here a link that was passed to me that may prove promising ( Avoiding Excessive Security Warnings when Sending Automated E-mail Messages). This deals with problems I have already encountered using this method. Hopefully this link will enable me to get around them.
Good link NeoPa, shows that when SMTP is allowed the CDO is the easy way to "bypass" the Outlook Object model build-in warnings. Guess the "morons" found that too <LOL>
Nic;o)
NeoPa 32,556
Expert Mod 16PB
I'm afraid so Nico. There was a flood of virus payloads which included a basic SMTP engine that ran on the PC itself :(
I first found that out when an Exchange server I was responsible for was flagged as an open relay (it would allow SMTP messages to be sent on when it determined the address was not local). I had to fix it and then apply to be rechecked before I could get it removed from the blacklist (Various servers were refusing to accept any mail from us).
It seems there were two methods used by the virus software : - SMTP via the local mail server. This gives the e-mails the impression of being more kosher.
- SMTP straight out to the web.
To block the first I needed to tighten up the security on my Exchange server. To block the second I needed to block SMTP traffic on the firewall from all internal addresses except my Exchange server.
As you will see, this doesn't leave much scope for a general purpose SMTP based routine in my code :(
Hello Neo,
I am now ready to look at the e-mail part of my app. Would you mind sending me anything you have got working (in particular how you got around the security messages). I will even trade if need be. I just created a very nice Calendar that allows you to add events such as meetings, to-do, etc., multiple participants, and such. I could trade you that if a calendar/scheduler is of any use to you.
You can PM me for email address.
cheers,
Rob
NeoPa 32,556
Expert Mod 16PB
Rob,
My e-mail project has been delayed further.
I am now using FTP to transfer this current set of files to the customer, although I would like to include e-mailing in my repertoire once this is finished. I hope to reduce the manual workload considerably by enabling this.
I haven't made much further progress than my last post on this though I'm afraid. I have the ability to code the sending of the mail, but the security is something I've only found links for.
I suggest, unless you have similar restrictions yourself with respect to SMTP, that you check out what CDO can do for you (Re Nico's post). If not, check out my earlier link and see if you can make some progress with that.
PS. Thanks for the offer of your code. I'll bear it in mind if ever I need something along those lines. I'm also more than happy to share anything I manage to come up with if it can be of any use to you. Unfortunately, that's not likely to start for some weeks now, and even that's assuming other priority work is not inserted ahead of it (I hope not though as this is something I really want to get cracked).
NeoPa 32,556
Expert Mod 16PB
This module (only half-finished I'm afraid) is as far as I've got so far. Nothing's finished yet (specifically some comments not implemented yet) but SendEM can send an email - albeit with all the security popups getting in the way :( - Option Compare Database
-
Option Explicit
-
-
Private appOutlook As Outlook.Application
-
-
'SendEM Sends an email
-
'For each address, any text found in <> will be treated as an SMTP address.
-
'An attempt is first made to refer to an object with a matching name.
-
'If this succeeds, but the address is ambiguous, the SMTP address will be used
-
' to resolve it.
-
'If no matching item is found then it will create a simple SMTP: entry
-
' of the following format : "Display Name<SMTP Address>".
-
Public Function SendEM(Optional ByVal strTo As String, _
-
Optional ByVal strCC As String, _
-
Optional ByVal strBCC As String, _
-
Optional ByVal strSubject As String, _
-
Optional ByVal strBody As String, _
-
Optional ByVal strAttachments As String) As Boolean
-
Dim blnOpen As Boolean
-
Dim strItem As String
-
Dim miMail As MailItem
-
-
SendEM = False
-
blnOpen = Not (appOutlook Is Nothing)
-
If Not blnOpen Then
-
On Error Resume Next
-
Set appOutlook = GetObject(Class:="Outlook.Application")
-
On Error GoTo 0
-
blnOpen = Not (appOutlook Is Nothing)
-
If Not blnOpen Then _
-
Set appOutlook = CreateObject(Class:="Outlook.Application")
-
End If
-
With appOutlook
-
Set miMail = .CreateItem(ItemType:=olMailItem)
-
With miMail
-
Call .Display
-
Call AddRecipient(miMail, strTo, olTo)
-
Call AddRecipient(miMail, strCC, olCC)
-
Call AddRecipient(miMail, strBCC, olBCC)
-
.Subject = strSubject
-
.Body = strBody & .Body
-
Call .Send
-
End With
-
If Not blnOpen Then Set appOutlook = Nothing
-
End With
-
End Function
-
-
Private Function AddRecipient(ByRef miMail As MailItem, _
-
strList As String, _
-
lngType As Long) As Boolean
-
Dim varItem As Variant
-
-
With miMail.Recipients
-
For Each varItem In Split(strList, ";")
-
With .Add(varItem)
-
.Type = lngType
-
AddRecipient = Not .Resolve
-
If AddRecipient Then Exit Function
-
End With
-
Next varItem
-
End With
-
End Function
-
-
'Some sample code from Microsoft
-
' function to attempt ambiguous name resolution (ANR)
-
Private Function TryANR(objRecip As Recipient) As Boolean
-
Dim objAmbigEntries As AddressEntries ' possible resolutions
-
Dim strChosenID As String ' ID of address entry chosen by user
-
-
' ... set up error handling ...
-
Set objAmbigEntries = objRecip.AmbiguousNames
-
If objAmbigEntries Is Nothing Then
-
MsgBox "No eligible names for resolution"
-
objRecip.Delete ' nothing else can be done at this point
-
TryANR = False
-
Else
-
' show address entries to user so one can be chosen, and save its
-
' entry identifier: strChosenID = objAddrEntry.ID
-
objRecip.ID = strChosenID
-
TryANR = True
-
End If
-
End Function
-
-
Public Function SendItem(Optional ByVal strTo As String, _
-
Optional ByVal strCC As String, _
-
Optional ByVal strBCC As String, _
-
Optional ByVal strSubject As String, _
-
Optional ByVal strBody As String, _
-
Optional ByVal strAttachments As String) As Boolean
-
-
End Function
Thanks. I just started to look into the email problems and it looks like Extended MAPI might be the way to go instead of standard MAPI. Extended MAPI eliminates the problems of popups. If I get the Extended MAPI to work I will let you know.
cheers,
NeoPa 32,556
Expert Mod 16PB
Cheers Rob.
If that proves true (& I may get to start looking again in mid August sometime if things go according to plan) then I too will be very interested.
If I get anywhere I'll keep you posted :)
NeoPa 32,556
Expert Mod 16PB
Did you ever get anywhere with this Rob?
I'm not working on it again, but I'm still interested to see code reflecting a technique that can both be safe, and bypass the security warnings.
@NeoPa
Sorry for the delay Neo. I haven't checked for a few days. I am intending to try to get this working http://www.codeproject.com/KB/IP/CMapiEx.aspx. I have talked to the developer and he thinks it should work but has not tried it in VBA. It does work in VB.
I did not have time for my project to check in detail so I had to go with a commercial version so I went with MAILBEE.
But I would like to try and get the above free version working. When I get time I will look into it some more.
cheers,
NeoPa 32,556
Expert Mod 16PB
Sounds interesting. Likewise I don't have the scope to devote time to this at work atm. I'll catch any future posts on here though. Also, I'll post if I manage to get any progress myself.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kurt |
last post by:
Hi
We are developing an off-the-shelf software suite for a certain business sector. Most of the program is simply a GUI on top of some .mdb files. Its a .net application written in c#
One...
|
by: scott |
last post by:
Anyone have a link to syntax that could create an outlook vcard file format?
all examples i find are for doing it inside outlook with .net. i'm just
looking for an ASP solution.
|
by: lauren quantrell |
last post by:
Is there a way to open the MS Outlook address book using VBA and then
be able to do something with the return value?
I want users to click an icon to open the Outlook address book then
when an...
|
by: Bob Avallone |
last post by:
MetaPro Systems Inc. Visual Studio Dot Net Tips & Tricks #3 – Direct
Access to
Your Outlook Address Book.
Project Type: VS.NET Windows Application
Code Behind: Visual Basic
I have a project...
|
by: TM |
last post by:
I would like to write a little app in Visual Basic .net as an add-in to
Outlook 2003 so that I can quickly get a list of contact names and email
addresses, then when I click on a name or email...
|
by: charliej2001 |
last post by:
Hi all
My access database has import/export capabiltiy of contact details
between outlook. The database is getting big now (1000+ contacts) and
so are the outlook address books that have the...
|
by: kannan |
last post by:
Hi,
I am new to C# and It may be a simple question.
I am trying to loop through MS-Outlook object Contact address list. I can
able to find the count using following line.
int iAddresscount =...
|
by: kannan |
last post by:
Hi,
I am trying to loop through outlook contact address and display in
messagebox.
I have used following code:
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace...
|
by: Phil Stanton |
last post by:
I have a Yacht Club Db with names addresse phone nos, emails etc.
I want to export them to Outlook. No problem in getting them into the
contact folder.
My problem is I have a folder within the...
|
by: mkhan |
last post by:
Hi, i have been having trouble how to open the To Contacts list (address book) of a mail message in outlook using vb.net from where the user would be able to select a email address and would be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
| |