Ga naar inhoud

Automatisch alles mailen uit Excel


anoniem

Aanbevolen berichten

Ik heb een vraagje over een VB scrippie. Ik wil nl. vanuit Excel automatisch mailtjes kunnen versturen. Het Excelsheet dat ik heb ziet er als volgt uit : email@bladiebla.nl onderwerp body, die bestaat uit meerdere regels onder elkaar, meestal een stuk of 8 ...... email2@bladiebla.nl onderwerp2 body, die bestaat uit meerdere regels onder elkaar, meestal een stuk of 8 ...... email3@bladiebla.nl onderwerp3 body, die bestaat uit meerdere regels onder elkaar, meestal een stuk of 8 ...... enz. Nu had ik al iets als : Code: Sub stuurmail() Dim Out As Outlook.Application Dim geadresseerde As String Dim onderwerp As String Dim inhoud As String Set Out = New Outlook.Application Dim p As mailitem Set p = Out.CreateItem(olmailitem) Do Until ActiveCell = "x" geadresseerde = Range("A1").Value onderwerp = Range("A2").Value inhoud = Range("A3", "A5").Group (DEZE KLOPT NIET !!) p.Recipients = (geadresseerde) p.Subject = (onderwerp) p.body = (inhoud) p.send ActiveCell.Offset(1, 0).Select Loop End Sub Maar kom eigenlijk geen stap verder. Iemand die er sjoege van heeft ?
Link naar reactie
  • 6 maanden later...
Een heel oude topic, ik weet het, maar ik heb het al enige tijd draaiende met een macro die ik ergens heb gevonden. Echter, deze is vrij complex, en daarom ben ik eens gaan zoeken. Ik kwam het volgende tegen : [code:1:9ebf828428] In the second section, the e-mail is send automatically using the following procedure. Public Sub Auto_Mail_Send() Dim lresult As Long Dim msg As MapiMessage Dim lSess As Long Dim r As MapiRecip Dim sName As String Dim f As MapiFile Dim rowCount As Integer Dim Count As Integer Dim MyPath As String 'Get the currect path MyPath = CurDir rowCount = 2 Set MyTable = ActiveDocument.Tables(2) 'the last two characters need to be removed from the 'table cell values used below While ActiveSheet.Cells(rowCount, 4).Value <> "" r.Address = ActiveSheet.Cells(rowCount, 4).Value r.RecipClass = MAPI_TO msg.Subject = ActiveSheet.Cells(rowCount, 2).Value + " " + ActiveSheet.Cells(rowCount, 1).Value msg.NoteText = ActiveSheet.Cells(rowCount, 3).Value msg.RecipCount = 1 lresult = MAPILogon(0, "", "", 0, 0, 0) lresult = MAPISendMail(0, 0, msg, r, f, 0, 0) lresult = MAPILogoff(0, 0, 0, 0) rowCount = rowCount + 1 Wend 'Change the path back from the email application ChDir MyPath MsgBox "FINISHED SENDING MULTIPLE EMAILS!" Set MyTable = nothing End Sub • The first thing you might notice is that the names for user defined types have been changed. For example, “Dim f As MapiFile”. The main reason is to make the code easier to read, especially if you are passing lots of variables to a function. • The next thing you might notice is that the current directory is read into a variable at the beginning of the procedure, then the current directory is set to this variable at the end of the procedure. This is because the current directory is changed to the your email client directory. So when you go to save later, you will save to the wrong folder. Its not funny trying to work out why the latest changes you made in a document have disappeared all of a sudden. • You will notice that the “MAPISendMail” function is preceded by a “MAPILogon” function, and followed by a “MAPILogoff” function. This is necessary if you are going to send lots of e-mail to prevent errors. • The rest of the code is pretty straight forward. You can easily see the possibilities for this automatic sending of e-mails. [/code:1:9ebf828428] Mijn vraag luidt nu : Is het mogelijk (daar ik de verzonden mailtjes dus NIET in mijn Sent Items te zien krijg !) om hiervan BCC's naar 1 ander emailadres te sturen, en zo ja, welke regels moet ik dan toevoegen ?[/code]
Link naar reactie

Om een reactie te plaatsen, moet je eerst inloggen

Gast
Reageer op dit topic

×   Geplakt als verrijkte tekst.   Herstel opmaak

  Er zijn maximaal 75 emoji toegestaan.

×   Je link werd automatisch ingevoegd.   Tonen als normale link

×   Je vorige inhoud werd hersteld.   Leeg de tekstverwerker

×   Je kunt afbeeldingen niet direct plakken. Upload of voeg afbeeldingen vanaf een URL in

  • Populaire leden

    Er is nog niemand die deze week reputatie heeft ontvangen.

  • Leden

    Geen leden om te tonen

×
×
  • Nieuwe aanmaken...