Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | Anybody good wih VB code?

You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > General IT Discussion
Register FAQ Community Calendar

Anybody good wih VB code?
Reply
 
Thread Tools
Old 07-06-2006, 15:05   #1
LSainsbury
Guest
 
Location: Near Hungerford, West Berkshire
Services: TV: Sky HD, Landline: BT, Mobile: Orange, Internet: Quite Slow!
Posts: n/a
Exclamation Anybody good wih VB code?

Anybody here good with VB code?

One of my customers is trying to send out some mailshot using MS Access with intergrates with Outlook to send the email.

They don't want the email to be from internalemployeename@company.co.uk but to use enquiries@company.co.uk.

The code I have been given is like this:

Quote:
Sub SendMessages(Optional AttachmentPath)

Dim MyDB As DAO.Database
Dim MyRS As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim TheAddress As String

Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("tblMailingList")
MyRS.MoveFirst

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

Do Until MyRS.EOF
' Create the e-mail message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
TheAddress = MyRS![strEmailAddress]

With objOutlookMsg
' Add the To recipients to the e-mail message.
Set objOutlookRecip = .Recipients.Add(TheAddress)
objOutlookRecip.Type = olTo

' Add the Cc recipients to the e-mail message.
'If (IsNull(Forms!frmMail!CCAddress)) Then
'Else
' Set objOutlookRecip =
.Recipients.Add(Forms!frmMail!CCAddress)
' objOutlookRecip.Type = olCC
'End If

' Set the Subject, the Body, and the Importance of the e-mail message.
.Subject = Forms!frmMail!strSubject
.Body = Forms!frmMail!strText
.Importance = olImportanceHigh 'High importance

'Add the attachment to the e-mail message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

' Resolve the name of each Recipient.
'For Each objOutlookRecip In .Recipients
' objOutlookRecip.Resolve
' If Not objOutlookRecip.Resolve Then
' objOutlookMsg.Display
' End If
'Next
.Send
End With
MyRS.MoveNext
My question is - is there a string of code which they can add /change so the email forced out with the senders address as enquiries@company.co.uk?

Thanks for the advice!
  Reply With Quote
Advertisement
Old 07-06-2006, 15:25   #2
Acathla
Inactive
 
Join Date: Jun 2003
Posts: 1,354
Acathla has reached the bronze age
Acathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze age
Re: Anybody good wih VB code?

hmm i am sure you can set a .From in the Oulook object...

left my program days a while back so am not 100%

Edit:
I know it sounds crazy but before

Quote:
.Subject = Forms!frmMail!strSubject
put

Quote:
.From = enquiries@company.co.uk
does it work :oooo

EDIT:

I suck
Acathla is offline   Reply With Quote
Old 07-06-2006, 15:33   #3
gazzae
Inactive
 
gazzae's Avatar
 
Join Date: Jun 2003
Location: Belfast
Age: 46
Posts: 4,594
gazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronze
gazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronze
Re: Anybody good wih VB code?

Nah you can't do that with from. you have to use .SentOnBehalfOfName
gazzae is offline   Reply With Quote
Old 07-06-2006, 15:36   #4
LSainsbury
Guest
 
Location: Near Hungerford, West Berkshire
Services: TV: Sky HD, Landline: BT, Mobile: Orange, Internet: Quite Slow!
Posts: n/a
Re: Anybody good wih VB code?

So write it like this:


.Subject = Forms!frmMail!strSubject
.From = enquiries@company.co.uk


...with the .From entry directly under the .Subject??

Correct?

---------- Post added at 15:36 ---------- Previous post was at 15:34 ----------

Quote:
Originally Posted by gazzae
Nah you can't do that with from. you have to use .SentOnBehalfOfName
Can you give me that in actual code please? ie where it needs to go within the code?

My coding skills are krap!!

Thanks

Lee
  Reply With Quote
Old 07-06-2006, 15:36   #5
Acathla
Inactive
 
Join Date: Jun 2003
Posts: 1,354
Acathla has reached the bronze age
Acathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze age
Re: Anybody good wih VB code?

Quote:
Originally Posted by gazzae
Nah you can't do that with from. you have to use .SentOnBehalfOfName
ok so like .SentOnBehalfOfName = enquiries@company.co.uk ?
Acathla is offline   Reply With Quote
Old 07-06-2006, 15:37   #6
gazzae
Inactive
 
gazzae's Avatar
 
Join Date: Jun 2003
Location: Belfast
Age: 46
Posts: 4,594
gazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronze
gazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronze
Re: Anybody good wih VB code?

.SentOnBehalfOfName = "enquires@company.com"
gazzae is offline   Reply With Quote
Old 07-06-2006, 15:40   #7
Acathla
Inactive
 
Join Date: Jun 2003
Posts: 1,354
Acathla has reached the bronze age
Acathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze ageAcathla has reached the bronze age
Re: Anybody good wih VB code?

So make you bit above say:

Quote:
.SentOnBehalfOfName = "enquires@company.com"
.Subject = Forms!frmMail!strSubject
.Body = Forms!frmMail!strText
.Importance = olImportanceHigh 'High importance
Acathla is offline   Reply With Quote
Old 07-06-2006, 15:42   #8
gazzae
Inactive
 
gazzae's Avatar
 
Join Date: Jun 2003
Location: Belfast
Age: 46
Posts: 4,594
gazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronze
gazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronze
Re: Anybody good wih VB code?

Yep pretty much.

Are you using exchange? If you have any problems you might need to check the permissions on the mailbox to let you send mail on behalf of others. IIRC.
gazzae is offline   Reply With Quote
Old 07-06-2006, 15:51   #9
LSainsbury
Guest
 
Location: Near Hungerford, West Berkshire
Services: TV: Sky HD, Landline: BT, Mobile: Orange, Internet: Quite Slow!
Posts: n/a
Re: Anybody good wih VB code?

Wicked - thanks!

I'll pass it onto the customer and see what happens....

Will let you know tomorrow morning...

---------- Post added at 15:51 ---------- Previous post was at 15:42 ----------

Quote:
Originally Posted by gazzae
Yep pretty much.

Are you using exchange? If you have any problems you might need to check the permissions on the mailbox to let you send mail on behalf of others. IIRC.
Yep - but it's not a mailbox - it's a DL. I've given delagte permissions on the DL - I think ....err I hope!
  Reply With Quote
Old 07-06-2006, 16:10   #10
Gareth
cf.mega poster
 
Gareth's Avatar
 
Join Date: Dec 2003
Age: 51
Posts: 7,101
Gareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny stars
Gareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny stars
Re: Anybody good wih VB code?

Yep, gazzae is spot-on. For security reasons (to stop people spoofing from addresses ...although it can be done anyway, just not in VB) you have to use .SentOnBehalfOfName()

More info, and some snippets of code here - http://support.microsoft.com/?kbid=232309
Gareth is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:32.


Server: lithium.zmnt.uk
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum