Opening a new Email from Access (1 Viewer)

jessss

Registered User.
Local time
Today, 10:16
Joined
Jan 17, 2010
Messages
29
[Solved] Opening a new Email from Access

Hi, i have a VBA module which creates a new email from access and populates it with a send to address, subject and message body.

However i have been told to amend any code within this access system so that it points SMTP taffic towards a new SMTP solution.

As my VBA module does not send the email it just opens it on screen for the user to check/amend before sending it, i don't think changes to SMTP should affect my VBA module however i am unsure. Does anyone know whether i need to amend the code for SMTP changes?

Code:
    Dim olNS As Outlook.NameSpace
    Dim olfolder As Outlook.MAPIFolder

    Dim olMailItem As Outlook.MailItem
    
    Dim strBodyText As String
    
    Set olApp = CreateObject("Outlook.Application")
    Set olNS = olApp.GetNamespace("MAPI")
    Set olfolder = olNS.GetDefaultFolder(olFolderInbox)
    Set olMailItem = olfolder.Items.Add("IPM.Note")

    olMailItem.Display

    strBodyText = "Dear " & Me.IFA_TITLE & " " & Me.IFA_SUR & "," & vbCrLf & vbCrLf & _
    
    With olMailItem
        .Subject = "Me.AppRefID & " - " & Me.Title & " " & Me.FirstName & " " & Me.AppName
        .To = Me.IFA_EMAIL
        .Body = strBodyText
'        .Send
    End With
    
    Set olMailItem = Nothing
    Set olfolder = Nothing
    Set olNS = Nothing
    Set olApp = Nothing
Thanks


Jessica
 
Last edited:

Ranman256

Well-known member
Local time
Today, 05:16
Joined
Apr 9, 2015
Messages
4,337
The vb code controls Outlook.
Outook controls the email. (And SMTP)
 

jessss

Registered User.
Local time
Today, 10:16
Joined
Jan 17, 2010
Messages
29
Thank you for replying. So i would need to recode the VBA so it uses the corrcet SMTP location?
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:16
Joined
Sep 21, 2011
Messages
14,301
Thank you for replying. So i would need to recode the VBA so it uses the corrcet SMTP location?

I would say No, if your company is now using the new SMTP server for their mail.? I do not even use email addresses, just unique names, so that if a person changes their email address, then it only need to be changed within Outlook.

If not, then, YES, you would need to amend substantially I would have thought.
 

jessss

Registered User.
Local time
Today, 10:16
Joined
Jan 17, 2010
Messages
29
I believ Outlook is currently using the new SMTP. SO is it that access uses what ever SMTP outlook is using?
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:16
Joined
Sep 21, 2011
Messages
14,301
I believ Outlook is currently using the new SMTP. SO is it that access uses what ever SMTP outlook is using?

Correct. Access just instructs/requests Outlook to send an email.

So nothing to change.?
 

jessss

Registered User.
Local time
Today, 10:16
Joined
Jan 17, 2010
Messages
29
Thankfully no, yay much happier now.. Thank you so much for your help it is greatly appricated
 

Users who are viewing this thread

Top Bottom