I recall in at least two episodes of Star Trek (By Any Other Name from the original series and Where No One Has Gone Before from The Next Generation) that there is reference to and contact with species from external galaxies. By the 29th century, we see that timeships exist. My question is, is there any reference to intergalactic relations in Star Trek in the future (say, by the 29th Century), or does the Star Trek Universe stay in the Milky Way Galaxy?
Aside from a few unusual strayings outside the galaxy, such as in TNG 1x06 Where No One Has Gone Before, and visitors from outside the galaxy, no, we're pretty much confined to our galaxy due to the Galactic Barrier:
Entering the barrier was extremely hazardous. Shields could not block all the energies of the barrier; the leakage was sufficient to heat up the hull to over 2,000 degrees, (TOS: "By Any Other Name") damage several systems and disable the warp drive of the Enterprise. Also passing the shields and hull were strange electric shocks to the nervous systems of the human crew members with high esper ratings. In most cases this caused death from brain damage.
Individuals with the highest ESP ratings such as Dr. Elizabeth Dehner's 089 and Lieutenant Commander Gary Mitchell's 091 survived the shock and were altered as a result. They developed a multitude of psionic powers at a geometric rate. They began to view their former friends and shipmates as lower lifeforms. This transformation was known to have happened at least three times, with the best known example being Mitchell. (TOS: "Where No Man Has Gone Before")
The barrier doesn't have an explanation in canon, but the Q Continuum novels explain that it was created by the Q in order to keep out 0, the being that had destroyed the Tkon Empire.
No, not directly. But at least one of the guys who worked on the franchise, Star Trek:Enterprise's production illustrator Doug Drexler, thought there would be, in at least one future timeline.
In Star Trek:Enterprise's episode "Azati Prime" we are shown the 26th Century starship Enterprise NCC 1701-J which was designed by Doug Drexler. Here is a quote from Memory Alpha in regards to it.
Drexler saw the Enterprise-J "as a multi-generational vessel, that had large parks, entertainment zones, and entire universities on board. The ship is so large that turbolifts would be replaced with site to site transporters. [It] had one deflector, recognizably descended from the NX. I opted for spindly nacelle struts because I felt it suggested a technology beyond what we were familiar with. They are beyond transwarp. They can fold space, and they are exploring other galaxies besides the Milky Way."
So obviously it's only background detail, and it's background detail to a now impossible future, but I think it shows the guys behind the scenes were thinking about it.
The TOS episode "The Alternative Factor" has a statement indicating possible communication with places outside the Milky Way galaxy.
BARSTOW [on viewscreen]: You're aware of the effect an hour ago?
KIRK: Yes, sir.
BARSTOW [on viewscreen]: You may not be aware of its scope. It occurred in every quadrant of the galaxy and far beyond. Complete disruption of normal magnetic and gravimetric fields, timewarp distortion, possible radiation variations. And all of them centring on the general area which you are now patrolling. The question is, are these natural phenomena or are they mechanically created, and if they are, by whom? For what purpose? Your guess, Captain.
So taken on face value this one episode seems to indicate that Starfleet has ultrafast communications with societies and/or sensing equipment outside the galaxy.
They could also just have scientific instruments that recorded the effect on places within and outside our galaxy. Since it's been shown that instruments like telescopes and sensors are not bound by the speed of light, they might have registered the effects on globular clusters orbiting the Milky Way, for example, thus being able to determine that the event wasn't constrained to the Milky Way only.– SavaJan 26, 2019 at 16:32