E-mail Address

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
The following code you gave me changes the words of a field for the contacts I select.

So I want this to do the following: Add the email address to the contact equal to the First Name.Last Name@BankName.com

So can we change this?

Sub AddCurrentLastStatusFieldsandDateFields_Marketing_E_mail_Sent_Reminder_Value()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
On Error Resume Next
If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem
objItem.UserProperties("Last Status Date") = Now()
objItem.UserProperties("Last Status") = "Marketing E-mail Sent - Reminder Value"
objItem.UserProperties("Follow-Up?") = "Yes"
objItem.UserProperties("Date to Follow- Up") = DateAdd("m", 1, objItem.UserProperties("Last Status Date"))
objItem.UserProperties("Start Date") = objItem.UserProperties("Date to Follow- Up")


objItem.UserProperties("Next Step") = "E-mail To Stay in Touch"


objItem.Save
GoTo Leave
End If
Set objSelection = objApp.ActiveExplorer.Selection
For Each objItem In objSelection


objItem.UserProperties("Last Status Date") = Now()
objItem.UserProperties("Last Status") = "Marketing E-mail Sent - Reminder Value"
objItem.UserProperties("Follow-Up?") = "Yes"
objItem.UserProperties("Date to Follow- Up") = DateAdd("m", 1, objItem.UserProperties("Last Status Date"))
objItem.UserProperties("Start Date") = objItem.UserProperties("Date to Follow- Up")


objItem.UserProperties("Next Step") = "E-mail To Stay in Touch"
objItem.Save
Next
Leave:
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
 
Are you adding it to a new field or adding it to a value in a current field? Creating an email address isn't hard - i assume bankname = company name?

Code:
objItem.firstname & "." &  objItem.lastname & "@" & replace(objItem.companyname, " ", "") & ".com"

replace is used to remove any spaces between words in the company name.
 
Add to the Email1 field. ill try it but can you show me where to put it and what to delete please?
 
I'm not sure where you want it - do you want it in the email address field (objitem.email1address) or one of your custom fields?
 
Then after this line:

Set objItem = objApp.ActiveInspector.currentItem

add this:

objitem.email1address = objItem.firstname & "." & objItem.lastname & "@" & replace(objItem.companyname, " ", "") & ".com"

Oh, and if the first or last name fields have spaces at the end, you can use trim(objItem.lastname) to remove leading or following spaces.
 
oh, you'll also want it after For Each objItem In objSelection so that it works on selected items. As for deleting, any or all of the objItem.UserProperties* lines you don't want to change.
 
I am now at my office and will try it and report back to you
 
I am now at my office and will try it and report back to you
 
I just did the following at it does re the Company Name in the Contact....but if I don't want to use the company name and just put in the code the words as if it is a company name, I changed Replace(objItem.CompanyName, " ", "") to simple the words in between " " and it did not work...so I want to use the first name.last name@ the words I put in the code.com....can you tell me what to do please?

Sub AddCurrentEmailAddress()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
On Error Resume Next
If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem
objItem.Email1Address = objItem.FirstName & "." & objItem.LastName & "@" & Replace(objItem.CompanyName, " ", "") & ".com"
objItem.Save
GoTo Leave
End If
Set objSelection = objApp.ActiveExplorer.Selection
For Each objItem In objSelection
objItem.Email1Address = objItem.FirstName & "." & objItem.LastName & "@" & Replace(objItem.CompanyName, " ", "") & ".com"
objItem.Save
Next
Leave:
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
 
I just did the following at it does re the Company Name in the Contact....but if I don't want to use the company name and just put in the code the words as if it is a company name, I changed Replace(objItem.CompanyName, " ", "") to simple the words in between " " and it did not work...so I want to use the first name.last name@ the words I put in the code.com....can you tell me what to do please?

Sub AddCurrentEmailAddress()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
On Error Resume Next
If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem
objItem.Email1Address = objItem.FirstName & "." & objItem.LastName & "@" & Replace(objItem.CompanyName, " ", "") & ".com"
objItem.Save
GoTo Leave
End If
Set objSelection = objApp.ActiveExplorer.Selection
For Each objItem In objSelection
objItem.Email1Address = objItem.FirstName & "." & objItem.LastName & "@" & Replace(objItem.CompanyName, " ", "") & ".com"
objItem.Save
Next
Leave:
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
 
I just did the following at it does re the Company Name in the Contact....but if I don't want to use the company name and just put in the code the words as if it is a company name, I changed Replace(objItem.CompanyName, " ", "") to simple the words in between " " and it did not work...so I want to use the first name.last name@ the words I put in the code.com....can you tell me what to do please?

Sub AddCurrentEmailAddress()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
On Error Resume Next
If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem
objItem.Email1Address = objItem.FirstName & "." & objItem.LastName & "@" & Replace(objItem.CompanyName, " ", "") & ".com"
objItem.Save
GoTo Leave
End If
Set objSelection = objApp.ActiveExplorer.Selection
For Each objItem In objSelection
objItem.Email1Address = objItem.FirstName & "." & objItem.LastName & "@" & Replace(objItem.CompanyName, " ", "") & ".com"
objItem.Save
Next
Leave:
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub

Just so you know, I posted the following but forgot to do in the other line as well, and did it and it works....thanks so much!!!
 
so this one is working now?
 
YES!! Thanks very much. And if you can, look back at the other post re the Outlook 2007 Search Through E-Mail
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Terry Sullivan Sender Field Displays My E-Mail Address, Not My Name Using Outlook 1
M Move new mail to folder based on sender address Outlook VBA and Custom Forms 2
Brostin Forward a mail to the address listed in the email text Outlook VBA and Custom Forms 1
C Why can junk mail be from one’s own email address? Using Outlook 7
I Collecting mail address from GAB and adding to Outlook Task Using Outlook 2
T Create Rule For Secondary E-Mail Address In Outlook 2016 Using Outlook 4
Diane Poremsky Make the Address Book show only e-mail addresses, not fax numbers Using Outlook 0
C Change From address while sending a new mail Outlook VBA and Custom Forms 5
L Adding sender's e-mail to global address book DL Outlook VBA and Custom Forms 1
D Cancelled Meeting Notifications to another mail address Outlook VBA and Custom Forms 1
T Outlook 2010 - Contacts associated with an e-mail address Using Outlook 1
D Show this folder as an e-mail Address Book is enabled but I want to disable Using Outlook 2
N Outllok adds unwanted period in my e-mail address Using Outlook 1
D Search for e-mail address Using Outlook 4
J Sending Mail From A Different Address Using Outlook 2011 for Mac Using Outlook 0
A How to forward all e-mails from one address to five (5) other e-mail address? Using Outlook 1
M How to clean duplicate/empty e-mail address fields in Outlook contacts Using Outlook 0
E hot to get the email address of an outlook mail item from "on behalf of" part Outlook VBA and Custom Forms 1
S Adding a mail address/recipient type field to a form Outlook VBA and Custom Forms 1
J Using Access to obtain E-mail address Outlook VBA and Custom Forms 5
F E-MAIL ADDRESS Outlook VBA and Custom Forms 1
J RE: E-mail address of the meeting organizer Outlook VBA and Custom Forms 1
T Adding a CC address to a mail Outlook VBA and Custom Forms 6
P Limited Support for 3rd Party Mail in new Outlook? Using Outlook 1
T Exchange Server - Mail Delay Stamping Exchange Server Administration 0
L Error when exporting Sent Mail to Excel Outlook VBA and Custom Forms 6
X Run macro automatically when a mail appears in the sent folder Using Outlook 5
K How can I delete an e-mail from Outlook Using Outlook 1
L Help: set flag for sent mail to check if received an answer Outlook VBA and Custom Forms 2
A Macro Mail Alert Using Outlook 4
e_a_g_l_e_p_i MY Outlook 2021 changed the format of the shortcuts for mail, calendar etc. Using Outlook 10
Z Outlook 365 Automatically assign categories to incoming mail in a shared folder Round Robin Outlook VBA and Custom Forms 1
W Outlook 365 I am getting the "Either there is no default mail client" error when I try to send an email on excel Office 365 Using Outlook 1
D Gmail mail is being delivered to a different email inbox in Outlook App 2021 Using Outlook 2
P What is your strategy for dealing with SPAM and Junk Mail? Using Outlook 1
C Code to move mail with certain attachment name? Does Not work Outlook VBA and Custom Forms 3
T 1:1 Datatransfer from incoming mail body to customs form body Outlook VBA and Custom Forms 0
O Mail rule issue Using Outlook 3
A manual rule sends mail to wrong folder Using Outlook 5
Aussie Outlook 365 Rule runs manually but returns the error code "an unexpected error has occurred" when incoming mail arrives Using Outlook 1
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
Witzker Outlook 2019 Macro to answer a mail with attachments Outlook VBA and Custom Forms 2
D Outlook 2003 Mail Fails Using Outlook 1
Cathy Rhone Mail merge error message Using Outlook 1
R Sent emails show iCloud mail account not the alias Using Outlook 2
D Advanced e-Mail search on from/to contact group only searches for first 20 contacts in group Using Outlook 0
P Print attachments automatically and move the mail to an existing folder called "Ted" Outlook VBA and Custom Forms 4
P Importing other e-mail accounts into Outlook Using Outlook 1
lcarpay Stay in the mail folder pane after ctrl-1 Using Outlook 1
O Exchange Sync period only (e.g. last years mail) Using Outlook 0

Similar threads

Back
Top