Excel 2016 VBA - Insert a variable

Midas1

New Member
Joined
Mar 19, 2018
Messages
7
Hi,

VBA Code:
Set .SendUsingAccount = .Session.Accounts.Item("123@email.com")   work

Set .SendUsingAccount = .Session.Accounts.Item(Range("B3").Value)   does not work


Dim MyEmail As String
MyEmail = Range("B3").Value
Set .SendUsingAccount = .Session.Accounts.Item(Range(MyEmail)  does not work

How could I add my Range or my variable into the Session.Accounts.Item ??


Thanks,
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi there

It looks like you are missing a closing parentheses... try

VBA Code:
Set .SendUsingAccount = .Session.Accounts.Item(Range("B3").Value))
or
VBA Code:
Set .SendUsingAccount = .Session.Accounts.Item(Range(MyEmail))
 
Upvote 0
Either of the original codes should work as long as the correct sheet is being referenced and B3 contains the same value as the original mailbox name.
 
Upvote 0
Either of the original codes should work as long as the correct sheet is being referenced and B3 contains the same value as the original mailbox name.
VBA Code:
Dim MyEmail As String
MyEmail = Sheets("Mail").Range("B3").Value

Set .SendUsingAccount = .Session.Accounts.Item(Range(MyEmail))

Is it the correct way to reference the sheet? Still not working
 
Upvote 0
VBA Code:
Dim MyEmail As String
MyEmail = Sheets("Mail").Range("B3").Value

Set .SendUsingAccount = .Session.Accounts.Item(Range(MyEmail))

Is it the correct way to reference the sheet? Still not working
Just:

Code:
.Session.Accounts.Item(MyEmail)
 
Upvote 0

Forum statistics

Threads
1,215,079
Messages
6,123,000
Members
449,092
Latest member
masterms

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top