{"id":576,"date":"2012-01-02T17:38:27","date_gmt":"2012-01-03T01:38:27","guid":{"rendered":"http:\/\/www.auval.com.mx\/notas\/?p=576"},"modified":"2012-01-02T17:38:27","modified_gmt":"2012-01-03T01:38:27","slug":"como-extraer-todos-los-correos-para-mandar-tarjetas-de-ano-nuevo","status":"publish","type":"post","link":"https:\/\/auval.com.mx\/blog\/2012\/01\/02\/como-extraer-todos-los-correos-para-mandar-tarjetas-de-ano-nuevo\/","title":{"rendered":"C\u00f3mo extraer todos los correos para mandar tarjetas de A\u00f1o Nuevo."},"content":{"rendered":"<p>Quer\u00eda mandar un correo de \u00abFeliz 2012\u00bb a todas las personas que me mandaron un correo este a\u00f1o. Para eso necesitaba una lista, as\u00ed que modifiqu\u00e9 ligeramente el c\u00f3digo de dos sitios muy \u00fatiles que menciono a continuaci\u00f3n. Con eso obtuve un archivo de texto que pude abrir en Excel para quitar a todos los amables spameros que me han mandado correo no solicitado, y luego casi todos los \u00abno-reply\u00bb, \u00abadmin\u00bb, \u00abreply\u00bb, \u00abinfo\u00bb, \u00abautomated\u00bb. Pero bueno, lo importante era tener la lista.<\/p>\n<p>De este lugar tom\u00e9 el c\u00f3digo:<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"kWneHVx1jb\"><p><a href=\"https:\/\/omaralzabir.com\/get_email_address_of_all_users_from_all_mails_in_outlook_folder\/\">Get email address of all users from all mails in Outlook Folder<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Get email address of all users from all mails in Outlook Folder&#8221; &#8212; Omar AL Zabir Blog\" src=\"https:\/\/omaralzabir.com\/get_email_address_of_all_users_from_all_mails_in_outlook_folder\/embed\/#?secret=igDjadjltH#?secret=kWneHVx1jb\" data-secret=\"kWneHVx1jb\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>De este saqu\u00e9 vbNewLine:<br \/>\nhttp:\/\/www.nsbasic.com\/desktop\/info\/Specifications.html<\/p>\n<p>Se oprime Alt-F11 y en el explorador de proyectos (que aparece oprimiendo Ctrl-R) se pega el c\u00f3digo, en \u00abeste proyecto de Outlook\u00bb.<\/p>\n<p>Es importante especificar una ruta y nombre de archivo v\u00e1lidos en la instrucci\u00f3n Const de la primera l\u00ednea.<\/p>\n<p>&nbsp;<\/p>\n<pre>Const c_archivo = \"F:\\Users\\armando\\Desktop\\email addresses 2.txt\"\n\nSub GetALLEmailAddresses()\n    Dim objFolder1 As MAPIFolder\n    Dim strEmail1 As String\n    Dim strEmails1 As String\n    Dim objItem As Object\n    Dim writeText As Boolean\n\n    Set objFolder1 = Application.GetNamespace(\"Mapi\").PickFolder\n    strEmails1 = GetMessages(objFolder1, True)\n    'strEmails1 = GetMessageEmails(objFolder1, True)\n    Debug.Print strEmails1\n    writeText = SaveTextToFile(c_archivo, strEmails1, True)\nEnd Sub\n\n'this is verbatem from http:\/\/www.freevbcode.com\/ShowCode.Asp, it saves the files to a text file\nPublic Function SaveTextToFile(FileFullPath As String, _\n    sText As String, Optional Overwrite As Boolean = False) As _\n    Boolean\n    'Purpose: Save Text to a file\n    'Parameters:\n    '- FileFullPath - Directory\/FileName to save file to\n    '- sText - Text to write to file\n    '- Overwrite (optional): If true, if the file exists, it\n    'is overwritten. If false,\n    'contents are appended to file\n    'if the file exists\n    'Returns: True if successful, false otherwise\n    'Example:\n    'SaveTextToFile \"C:\\My Documents\\MyFile.txt\", \"Hello There\"\n    On Error GoTo ErrorHandler\n    Dim iFileNumber As Integer\n    iFileNumber = FreeFile\n    If Overwrite Then\n        Open FileFullPath For Output As #iFileNumber\n    Else\n        Open FileFullPath For Append As #iFileNumber\n    End If\n    Print #iFileNumber, sText\n    SaveTextToFile = True\nErrorHandler:\n    Close #iFileNumber\nEnd Function\n\n'This is the GetMessages that takes a folder and returns a list of the \"name, e=mail, subject\"s\nPublic Function GetMessages(oFolder As MAPIFolder, ByVal bRecursive As Boolean) As String\n    Dim objFolder As Outlook.MAPIFolder\n    Dim strEmail As String\n    Dim strEmails As String\n    Dim strName As String\n    Dim strSubject As String\n    Dim strAll As String\n    Dim strItemAll As String\n    Dim objItem As Object\n    Dim objFolders As Outlook.Folders\n    Set objFolders = oFolder.Folders\n    For Each objFolder In objFolders\n        For Each objItem In objFolder.Items\n            If objItem.Class = olMail Then\n                strEmail = objItem.SenderEmailAddress\n                strName = objItem.SenderName\n                strSubject = objItem.Subject\n                ' ALFC I only want the emails.\n                'strItemAll = strName + \",\" + strEmail + \",\" + strSubject\n                strItemAll = strName &amp; \"|\" &amp; strEmail &amp; vbNewLine\n                strAll = strAll &amp; vbNewLine &amp; strItemAll\n            End If\n        Next\n        If bRecursive Then\n            ' Might want to compare this to strEmails instead of just appending.\n            strAll = strAll + GetMessages(objFolder, bRecursive)\n        End If\n    Next\n    GetMessages = strAll\nEnd Function\n\n'This is the the function that returns a list of \";\" delimited e-mails with no duplicates.\nPublic Function getMessageEmails(oFolder As MAPIFolder, ByVal bRecursive As Boolean) As String\n    Dim objFolder As Outlook.MAPIFolder\n    Dim strEmail As String\n    Dim strEmails As String\n    Dim objItem As Object\n    Dim objFolders As Outlook.Folders\n    Set objFolders = oFolder.Folders\n    For Each objFolder In objFolders\n        For Each objItem In objFolder.Items\n            If objItem.Class = olMail Then\n                strEmail = objItem.SenderEmailAddress\n                If InStr(strEmails, strEmail) = 0 Then strEmails = strEmails + strEmail + \";\"\"\"\n            End If\n        Next\n        If bRecursive Then\n            ' Might want to compare this to strEmails instead of just appending.\n            strEmails = strEmails + getMessageEmails(objFolder, bRecursive)\n        End If\n    Next\n    getMessageEmails = strEmails\nEnd Function<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Quer\u00eda mandar un correo de \u00abFeliz 2012\u00bb a todas las personas que me mandaron un correo este a\u00f1o. Para eso necesitaba una lista, as\u00ed que modifiqu\u00e9 ligeramente el c\u00f3digo de dos sitios muy \u00fatiles que menciono a continuaci\u00f3n. Con eso &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/auval.com.mx\/blog\/2012\/01\/02\/como-extraer-todos-los-correos-para-mandar-tarjetas-de-ano-nuevo\/\"> <span class=\"screen-reader-text\">C\u00f3mo extraer todos los correos para mandar tarjetas de A\u00f1o Nuevo.<\/span> Leer m\u00e1s \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[93,3],"tags":[],"class_list":["post-576","post","type-post","status-publish","format-standard","hentry","category-outlook","category-office"],"_links":{"self":[{"href":"https:\/\/auval.com.mx\/blog\/wp-json\/wp\/v2\/posts\/576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/auval.com.mx\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/auval.com.mx\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/auval.com.mx\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/auval.com.mx\/blog\/wp-json\/wp\/v2\/comments?post=576"}],"version-history":[{"count":0,"href":"https:\/\/auval.com.mx\/blog\/wp-json\/wp\/v2\/posts\/576\/revisions"}],"wp:attachment":[{"href":"https:\/\/auval.com.mx\/blog\/wp-json\/wp\/v2\/media?parent=576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/auval.com.mx\/blog\/wp-json\/wp\/v2\/categories?post=576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/auval.com.mx\/blog\/wp-json\/wp\/v2\/tags?post=576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}