473,396 Members | 1,703 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.

Send email to multiple addresses with atachments

DylaneJC
Hi everyone,

I need a help. I've been in many many forums looking for help but not satisfied.

Here is my trouble :

I want to send multiple email to multiple addresses located in my database. My database has an attachment field that I want to send directly to each line of the database.

Can someone can help me? I use IBM Lotus Notes.

Here is the code I use, but it doesn't want to take attachment from my database.


Expand|Select|Wrap|Line Numbers
  1. 'Sending e-mail to manager
  2. Private Sub Commande219_Click()
  3.  
  4. 'Variable
  5.   Dim rst As DAO.Recordset
  6.   Dim strSQL As String
  7.   Dim strMessageType As String
  8.   Dim strTitre As String
  9.   Dim strMsg As String
  10.  
  11.  
  12.  
  13.  
  14.  
  15.   ' Titre du message
  16.   strTitre = "{Objet} -- Résolu" _
  17.  
  18.  
  19.   ' Message to send
  20.   ' Les signes {...} seront remplacés plus loin par
  21.   ' les infos Client
  22.   strMessageType = "Bonjour," _
  23.     & vbCrLf & vbCrLf _
  24.     & "En date du {Date}, Nous avons reçu du client {Nom_Client} la réclamation en objet." & vbCrLf & vbCrLf _
  25.     & "Nous vous écrivons pour vous informer que cela a été pris en compte et désormais clôt." & vbCrLf _
  26.     & vbCrLf & "Nous vous souhaitons une bonne réception" _
  27.     & vbCrLf & vbCrLf & "~~ Service de Réclamations - UGB ~~"
  28.  
  29.   ' Open the querry
  30.   ' (seuls les gestionnaire ayant un email sont concernés ici)
  31.   strSQL = " SELECT * FROM [Reclamations] WHERE (((Reclamations.Etat)='Clôturée')) "
  32.  
  33.   Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
  34.  
  35.   ' Browse the client list
  36.   While Not rst.EOF
  37.     ' Construire un message personnalisé
  38.     ' (on remplace chaque {...} du message par les champs
  39.     ' équivalents de la requête
  40.     strMsg = Replace(strMessageType, "{Nom_Client}", rst("Nom_Client"))
  41.     strMsg = Replace(strMsg, "{Date}", rst("Date"))
  42.     strTitre = Replace(strTitre, "{Objet}", rst("Objet"))
  43.  
  44.  
  45.     'Send the e-mail
  46.     SendMail rst("E-mail_gest"), strTitre, strMsg, False
  47.  
  48.     ' Next client
  49.     rst.MoveNext
  50.   Wend
  51.  
  52.   ' One empty ressources
  53.   rst.Close
  54.   Set rst = Nothing
  55.  
  56.  
  57.   CurrentDb.Execute ("UPDATE Reclamations SET Reclamations.Etat = 'Archivée' WHERE (((Reclamations.Etat) = 'Clôturée')) ")
  58.  
  59.   ' A bit message of confirmation
  60.   MsgBox "E-mail de clôture envoyé aux gestionnaires!", vbInformation, "UGB -- Service de Réclamations"
  61. End Sub
Nov 29 '17 #1
8 2747
NeoPa
32,556 Expert Mod 16PB
Do you not want to leave some clues as to what's going wrong where? I doubt you'll get much interest if you can't even post your own question properly. Our experts will know you expect them to do more work on your problem that you're even prepared to do. We'll see how it goes. You may get very lucky.
Nov 30 '17 #2
Hi,

What I mean is this:

*I get a database which contains several coloumns (ID, Objet, Email, Attachment, ...)
*I have an Attachment field, which contains all the attachment inserted from a Form.

I want to send the same email to all my database addresses, including the attachment located in it.

This code is the module I use to send message :

Expand|Select|Wrap|Line Numbers
  1. '
  2. Public Sub SendMail(ByVal strEmail As String, _
  3.   ByVal strObj As String, _
  4.   ByVal strMsg As String, _
  5.   ByVal blnEdit As Boolean)
  6. On Error Resume Next
  7. DoCmd.SendObject acSendNoObject, , , strEmail, , , strObj, strMsg, blnEdit
  8. End Sub
  9.  
And here is the code to send message :

Expand|Select|Wrap|Line Numbers
  1. 'Sending e-mail to manager
  2. Private Sub Commande219_Click()
  3.  
  4. 'Variable
  5.   Dim rst As DAO.Recordset
  6.   Dim strSQL As String
  7.   Dim strMessageType As String
  8.   Dim strTitre As String
  9.   Dim strMsg As String
  10.  
  11.  
  12.  
  13.  
  14.  
  15.   ' Titre du message
  16.   strTitre = "{Objet} -- Résolu" _
  17.  
  18.  
  19.   ' Message to send
  20.   ' Les signes {...} seront remplacés plus loin par
  21.   ' les infos Client
  22.   strMessageType = "Bonjour," _
  23.     & vbCrLf & vbCrLf _
  24.     & "En date du {Date}, Nous avons reçu du client {Nom_Client} la réclamation en objet." & vbCrLf & vbCrLf _
  25.     & "Nous vous écrivons pour vous informer que cela a été pris en compte et désormais clôt." & vbCrLf _
  26.     & vbCrLf & "Nous vous souhaitons une bonne réception" _
  27.     & vbCrLf & vbCrLf & "~~ Service de Réclamations - UGB ~~"
  28.  
  29.   ' Open the querry
  30.   ' (seuls les gestionnaire ayant un email sont concernés ici)
  31.   strSQL = " SELECT * FROM [Reclamations] WHERE (((Reclamations.Etat)='Clôturée')) "
  32.  
  33.   Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
  34.  
  35.   ' Browse the client list
  36.   While Not rst.EOF
  37.     ' Construire un message personnalisé
  38.     ' (on remplace chaque {...} du message par les champs
  39.     ' équivalents de la requête
  40.     strMsg = Replace(strMessageType, "{Nom_Client}", rst("Nom_Client"))
  41.     strMsg = Replace(strMsg, "{Date}", rst("Date"))
  42.     strTitre = Replace(strTitre, "{Objet}", rst("Objet"))
  43.  
  44.  
  45.     'Send the e-mail
  46.     SendMail rst("E-mail_gest"), strTitre, strMsg, False
  47.  
  48.     ' Next client
  49.     rst.MoveNext
  50.   Wend
  51.  
  52.   ' One empty ressources
  53.   rst.Close
  54.   Set rst = Nothing
  55.  
  56.  
  57.   CurrentDb.Execute ("UPDATE Reclamations SET Reclamations.Etat = 'Archivée' WHERE (((Reclamations.Etat) = 'Clôturée')) ")
  58.  
  59.   ' A bit message of confirmation
  60.   MsgBox "E-mail de clôture envoyé aux gestionnaires!", vbInformation, "UGB -- Service de Réclamations"
  61. End Sub
The problem I encounter is when I select the attachment field with this code, I get an error telling that the "Data type is not compatible" .

Hope it's now clear. Thanks
Nov 30 '17 #3
NeoPa
32,556 Expert Mod 16PB
I won't pretend that this is something I feel I can help with Dylane, but if someone sees it and wants to help, can you tell us the line number in your recent post where the code stops and you see the message. When the code stops it gives an option to debug which, when selected, shows the code with the line it's on having a yellow background. It may be line #46 but I'm not sure.

In truth, we mostly recognise when someone struggles to express their problem but doesn't do it very well, compared to when someone is just too lazy to be bothered. Clearly you've tried so experts are likely to see that and try harder for you. Good luck.
Dec 1 '17 #4
Hi,

There is no error while runing that code. I just need to improve it so that I can send the attachments related to each email addresses in my database.

Also, instead of improving that code, if you get another code which can do the same thing by including the related attachment of each database fields, it'll be Good.



Thanks
Dec 1 '17 #5
NeoPa
32,556 Expert Mod 16PB
DylaneJC:
The problem I encounter is when I select the attachment field with this code, I get an error telling that the "Data type is not compatible".
How are you getting that error if there is no error?

I still don't believe I can help you Dylane, but if anyone else sees this and wants to they'll be more inclined to if they have a better understanding of what you're struggling with. Certainly the idea that other code is acceptable rather than the need to fix what you have may make it easier, but they may still be confused by what looks like a contradiction above. I doubt that's what you meant but it still looks that way.

Alternatively, if you'd like to buy a product that already handles such stuff for you there are many about. One I could vouch for, by an Access MVP friend, but can't here as that would be commercial which isn't allowed in these forums. So, all I can say is there are some out there that will save you a lot of trouble. You could do a search for access emailer and see what comes up. If what you find refers to Access MVP or Luke Chung then you'll have found the one I'm thinking of, but the web's a wonderful thing and you can choose whichever suits you, if you even want to go that way. It's just an idea.

Good luck.
Dec 1 '17 #6
Hi,

Sorry for beeing late.

the problem appear when I try this code :

Expand|Select|Wrap|Line Numbers
  1. 'Sending e-mail to manager
  2. Private Sub Commande219_Click()
  3.  
  4. 'Variable
  5.   Dim rst As DAO.Recordset
  6.   Dim strSQL As String
  7.   Dim strMessageType As String
  8.   Dim strTitre As String
  9.   Dim strMsg As String
  10.   Dim strAtt As Object
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.   ' Titre du message
  18.   strTitre = "{Objet} -- Résolu" _
  19.  
  20.  
  21.   ' Message to send
  22.   ' Les signes {...} seront remplacés plus loin par
  23.   ' les infos Client
  24.   strMessageType = "Bonjour," _
  25.     & vbCrLf & vbCrLf _
  26.     & "En date du {Date}, Nous avons reçu du client {Nom_Client} la réclamation en objet." & vbCrLf & vbCrLf _
  27.     & "Nous vous écrivons pour vous informer que cela a été pris en compte et désormais clôt." & vbCrLf _
  28.     & vbCrLf & "Nous vous souhaitons une bonne réception" _
  29.     & vbCrLf & vbCrLf & "~~ Service de Réclamations - UGB ~~"
  30.  
  31.   ' Open the querry
  32.   ' (seuls les gestionnaire ayant un email sont concernés ici)
  33.   strSQL = " SELECT * FROM [Reclamations] WHERE (((Reclamations.Etat)='Clôturée')) "
  34.  
  35.   Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
  36.  
  37.   ' Browse the client list
  38.   While Not rst.EOF
  39.     ' Construire un message personnalisé
  40.     ' (on remplace chaque {...} du message par les champs
  41.     ' équivalents de la requête
  42.     strMsg = Replace(strMessageType, "{Nom_Client}", rst("Nom_Client"))
  43.     strMsg = Replace(strMsg, "{Date}", rst("Date"))
  44.     strTitre = Replace(strTitre, "{Objet}", rst("Objet"))
  45.     strAtt = Replace(strAtt, "{Justificatif}", rst("Justificatif"))
  46.  
  47.  
  48.     'Send the e-mail
  49.     SendMail rst("E-mail_gest"), strTitre, strMsg, False
  50.  
  51.     ' Next client
  52.     rst.MoveNext
  53.   Wend
  54.  
  55.   ' One empty ressources
  56.   rst.Close
  57.   Set rst = Nothing
  58.  
  59.  
  60.   CurrentDb.Execute ("UPDATE Reclamations SET Reclamations.Etat = 'Archivée' WHERE (((Reclamations.Etat) = 'Clôturée')) ")
  61.  
  62.   ' A bit message of confirmation
  63.   MsgBox "E-mail de clôture envoyé aux gestionnaires!", vbInformation, "UGB -- Service de Réclamations"
  64. End Sub
Then the error appears on line 10 and 45.
Dec 5 '17 #7
NeoPa
32,556 Expert Mod 16PB
Late is fine Dylane. Carrying on a conversation without directing your responses to what's already been said is less so. If you aren't going to respond to my points/questions there's really very little point in my posting them. I expect that may be a language problem but if you don't understand you can always say so. Just moving on without regard to my comments can't possibly work.

Good luck anyway.
Dec 6 '17 #8
Hi,

Drop all down.

Thanks for all
Dec 6 '17 #9

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

Similar topics

1
by: Jay McGrath | last post by:
Help - trying to send a simple text email with with as little user intervention. I am trying to create a button in my Access application that will automatically send a simple text email. It...
7
by: Mega1 | last post by:
is this possable to send more than 1 report in one email
15
by: Rainman | last post by:
In the following simplified tag: <a href='mailto:<address1@somewhere.com>,<address2@nowhere.com>?subject=Testing'> click here</a> When clicked, both addresses appear as "To:" recipients when...
3
by: nt8jbwu02 | last post by:
Is it possible to use a single tcplistener to bind multiple addresses? Say I have three IP addresses and I want to bind two of the addresses on port 4000, but not the third. Can I do this...
1
by: divya | last post by:
I have a form which has a textarea,name - txtTo where he adds email addresses.Now when he clicks on sendemail I want to open a mailto link with addresses taken from textarea. Example I added...
3
by: sentiboy | last post by:
I am using the following code for sending email through mapi in VS 2005 environment: Public objSession As New MSMAPI.MAPISession Public objMessage As New MSMAPI.MAPIMessages ...
0
by: dreamsoul620 via AccessMonster.com | last post by:
Hi all! I'm trying to set up an email application for my database. I tried linking to my Outlook address book, but when reading from the table, I receive an error message saying I need to restart...
4
by: chris | last post by:
I need to maintain a list of subscribers to an email list for a "newsletter" that will be sent via a web form probably once a month. I anticipate low numbers--tens to maybe one hundred subscribers...
4
by: Wnicole | last post by:
I was hoping someone can look at this code and tell me what is missing It works all the way to outlook but once there it is not linking with the emails from the query on the report. It's sending the...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
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.